【发布时间】:2013-02-20 10:01:38
【问题描述】:
我的 xml
<?xml version="1.0" encoding="utf-8" ?>
<Category>
<Youth>
</Youth>
<GeneralStores>
</GeneralStores>
<Schools>
</Schools>
<Colleges>
</Colleges>
<GovernmentOffices>
</GovernmentOffices>
<Restaurants>
</Restaurants>
<MovieTheatres>
</MovieTheatres>
</Category>
我需要像这样的数据表
_______________________
Category
__________
Youth
GeneralStores
Schools
Colleges
GovernmentOffices
Restaurants
MovieTheatres
我在需要数据源事件时将此数据表绑定到 telrik rad 网格
这是我的 .cs 代码
protected void CategoriesRadGrid_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
try
{
//create the DataTable that will hold the data
DataTable CategoryDT = new DataTable("MainCategory");
CategoryDT.Columns.Add("Category", System.Type.GetType("System.String"));
CategoryDT.ReadXml(@"C:\Users\MyID\Documents\Visual Studio 2010\Projects\SomeName\InfoXML\XMLCategory.xml");
}
catch (Exception ex)
{
}
}
- 代码执行良好,数据表中没有数据。
- 还告诉我当文件在服务器上时如何给出文件位置? 目前我正在使用文件所在的本地机器路径。
【问题讨论】:
-
请记得为对您有帮助的答案投票。meta.stackexchange.com/questions/130046/when-should-i-vote
-
在
catch块中放置一个Debug.WriteLine(ex.ToString());,然后在调试器中运行它。你忽略了任何例外!