
How To Set Date in gridview Asceinding Order

3 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Vishal JoshiRank #377 · 6.7K reputationPosted Nov 28, 2022, 1:23 AM EST
Hello Sandeep,
Please try below code sample with you dataset to get the expected result.
var orderedData = dataList.OrderBy(x => x.Date).ToList(); GridView1.DataSource = ds; GridView1.DataBind();Thanks
Sandeep KumarRank #1,642 · 937 reputationPosted Nov 28, 2022, 2:38 AM EST
Aspx page
To Bind Gridview
Vishal JoshiRank #377 · 6.7K reputationPosted Nov 28, 2022, 7:30 AM EST
Hello Sandeep,
Try Below code to sort database columns.
dt.DefaultView.Sort = "sortColumn"; dt = dt.DefaultView.ToTable(); grvChemicalReport.DataSource = dt; grvChemicalReport.DataBind();Thanks