开发者

sort dropdownlist by date, after it is populated from datasource

开发者 https://www.devze.com 2023-02-04 15:55 出处:网络
开发者_JAVA技巧I want to sort the dropdownlist by date, but i cant figure out how. ddate.DataSource = myTable
开发者_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

精彩评论

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