I try to order Departments by number, but since the departement number stored as a string in database, I can't just use Order by number. I try to parse it as float but it did not work. Then I tried to parse it as Double. That does not work either. Any suggestions? The following is my code.
using (var db = new Context())
{
var datasource = (from x in db.Departments
orderby double.Parse(x.DepartmentNumber)
select x).ToList();
lvData.DataSource = datasource;
lvData.DataBind();
}
Thanks for the answer, I did the following, but the results are not entirly correct.
var datasource = (from x in db.Departments orderby x.DepartmentNumber select x).ToList().OrderBy(Department => float.Parse(Department.DepartmentNumber));