I have a gridview with some columns and I need to sort the gridview by a date-column. But I fail in sorting it correctly. This is the code that I use:
dt.DefaultView.Sort = "Meldingsdatum asc";
gvOutlookMeldingen.DataSource = dt;
gvOutlookMeldingen.DataBind();
Can someone help me, please.
http://forums.asp.net/p/1267353/2393006.aspx
DataView stores date or anything as string type. Thus when you sort it sort by string. To sort it as DateTime , you need to convert it to DateTime before adding any data as follows,
dt.Columns["Date"].DataType = Type.GetType("System.DateTime");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With