I have a query where i get some columns from database it is simple select statement then I add columns to this datatable as :
dt.Columns.Add(new DataColumn("ratio", typeof(double)));
Then I have another column called Rank which is again added manually as follow :
dt.Columns.Add(new DataColumn("Rank", typeof(int)));
now how do I first of all sort by ratio and then add rank using the ratio e.g. the higher the ratio the higher the rank for example if ratio is 3, 5 and 9 once ordered by ratio it should be :
rank ratio
1 9
2 5
3 3
EDIT :
the ratio is calculated by dividing the two columns in my query
foreach (DataRow row in dt.Rows)
{
row["Ratio"] = (Convert.ToDecimal(row["LastMonth"]) / NoOfBranches).ToString("0.##");
}
Thanks