【发布时间】:2012-10-30 13:32:23
【问题描述】:
我第一次尝试使用 xmldatasource,发现无法对其进行排序。如果你尝试你只会收到错误:“System.NotSupportedException:数据源不支持排序。”
GridView1.AllowSorting = true;
DataSet carsDataSet;
string filePath = Server.MapPath("App_Data/cars.xml");
carsDataSet = new DataSet();
//Read the contents of the XML file into the DataSet
carsDataSet.ReadXml(filePath);
GridView1.DataSource = carsDataSet.Tables[0].DefaultView;
GridView1.DataBind();
这会给我一个异常:“异常详细信息:System.Web.HttpException:未处理的 GridView 'GridView1' 触发事件排序。”
我的xml是这样的:
<Cars>
<car>
<id>11</id>
<make>Audi</make>
<model>A4</model>
<price>39000</price>
</car>
</Cars>
那么解决这个问题的最佳方法是什么?或者我可以以某种方式处理排序事件吗?或者将 xml 数据加载到 LINQ 或类似的东西会更容易吗?
【问题讨论】:
标签: asp.net .net gridview xmldatasource