2012-12-13 50 views
0

我有Asp.net應用程序和SqlDataSource ojbect調用t-sql sctored過程。它返回多個表(它的格式返回aboout 20個不同的表:。通過SqlDataSource循環如果底層SP返回多個表

1.table -> event1 data 
2.table -> event2 participation data 

3.table -> event2 data 
4.table ->event2 participation data 
etc. 

一切工作正常不過,我不明白如何讓所有這些表,從SqlDataSource的結果,我不需要任何的GridView或當我搜索如何將SqlDataSource轉換爲DataSet時,它建議使用SqlDataSource.Select - > get DataView - > convert toTable,但這個工作正常。僅用於一張桌子

回答

0

試試這個

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> 
+0

我沒有myAdap。我有SqlDataSource。沒有填充方法或類似方法。如果我在DataSet中有數據,那麼我現在如何循環。我不知道如何獲取這些數據。 – renathy