开发者

sort dropdownlist by date, after it is populated from datasource

开发者_JAVA技巧

I want to sort the dropdownlist by date, but i cant figure out how.

ddate.DataSource = myTable


    ddate.DataTextField = "ddate7"
    ddate.DataValueField = "ddate7"
    ddate.DataBind()


If myTable is a DataTable then you could put it into a Dataview and sort it there like this:

Dim dv As New DataView(myTable)
dv.Sort = "ddate7"

ddate.DataSource = dv
ddate.DataTextField = "ddate7"
ddate.DataValueField = "ddate7"
ddate.DataBind()


You can use a DataView to sort and filter the DataTable you may try the following code,

DataView dv = new DataView(myTable);
dv.Sort = "ddate7 ASC";
ddate.DataSource = dv;
ddate.DataTextField = "ddate7";
ddate.DataValueField = "ddate7";
ddate.DataBind();

Good luck.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜