开发者

ASP.NET Datalist Sorting (XMl Source)

开发者 https://www.devze.com 2023-01-16 17:27 出处:网络
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 displaye

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

精彩评论

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