开发者

ASP.NET Datalist Sorting (XMl Source)

I am populating a datalis开发者_JS百科t control with a simple xml source. It displays some Dates in whatever order they are displayed in the xml file. I want them to be sorted before they are displayed in the Datalist. Can this be done?


Depends on how you load the xml, if you load the XML into a dataset you can sort before binding.

DataSet myDataSet = new DataSet();
myDataSet.ReadXML("mydata.xml");
DataView myDataView = new DataView(myDataSet.Tables[0]);
myDataView.Sort = "mySortField ASC"; //or DESC

myDataListControl.DataSource = myDataView;
myDataListControl.DataBind();
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜