读xml文档中数据并对其进行排序,然后在datagrid中显示出来 1 .新建xml文档(books.xml) < items > < item > < iname > a </ iname > < iid > 1001 </ iid > < iamount > 12.34 </ iamount > </ item > < item > < iname > c </ iname > < iid > 002 </ iid > < iamount > 15.38 </ iamount > </ item > < item > < iname > c </ iname > < iid > 1280 </ iid > < iamount > 18.75 </ iamount > </ item > < item > < iname > e </ iname > < iid > 508 </ iid > < iamount > 20.55 </ iamount > </ item > </ items > 2 .编写代码 string dataUrl = " books.XML " ; DataSet ds = new DataSet(); ds.ReadXml(Server.MapPath(dataUrl)); DataView dv = new DataView(ds.Tables[ 0 ]); dv.Sort = " iname DESC,iid ASC " ; // 默认ASC(ascending) // DataTable dt = dv.Table; this .DataGrid1.DataSource = dv; // this.DataGrid1.DataSource=ds.Tables[0]; this .DataGrid1.DataBind(); 参考:http: // msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadataviewclasssorttopic.asp http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadataviewclasssorttopic.asp posted on 2006-01-17 13:55 DotNet编程 阅读( ...) 评论( ...) 编辑 收藏 转载于:https://www.cnblogs.com/furenjun/archive/2006/01/17/318932.html