我有一个带有SqlDataSource对象的Asp.net应用程序,它调用t-sql sctored过程。它返回多个表(它以以下格式返回20多个不同的表:
1.table -> event1 data
2.table -> event2 participation data
3.table -> event2 data
4.table ->event2 participation data
etc.
一切都很好。但是,我不明白如何从SqlDataSource结果中获取所有这些表。我不需要任何GridView或中继器。我需要手动循环遍历SqlDataSource结果。我不知道是怎么回事。
当我搜索如何将SqlDataSource转换为DataSet时,它建议SqlDataSource.Select -> get DataView -> convert toTable,但这只适用于一个表。
发布于 2012-12-13 13:52:15
尝尝这个
DataSet ds;
myAdap.Fill(ds);
if(ds.tables.count >0){
if(ds.tablles[0]..rows.cout >0){
foreach(datarow dr in ds.tables[0].rows){ //do someting with table 1}
}
if(ds.tables[1].rows.count>0){
foreach(datarow dr in ds.tables[1].rows){ //do seomthing with table 2}
}
}
ds.dispose();
<asp:SqlDataSource
ID="SqlDataSource1"
runat="server"
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
DataSourceMode="DataSet"
SelectCommand="SELECT TOP 25 ProductID, ProductName, UnitPrice FROM Products"
>
</asp:SqlDataSource>
https://stackoverflow.com/questions/13859694
复制