2010-03-05 53 views

回答

3

您可以使用SqlDataSourceSelect()方法來檢索數據,然後您可以將結果轉換爲DataViewDataReader

// Use the result as a DataView. 
    var dataview = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty); 
    foreach (DataRowView dataviewrow in dataview) 
    { 
     Label1.Text = dataviewrow["FirstName"].ToString(); 
    } 

    // Use the result as a DataReader. 
    var datareader = (SqlDataReader)SqlDataSource2.Select(DataSourceSelectArguments.Empty); 
    while (datareader.Read()) 
    { 
     Label2.Text = datareader["LastName"].ToString(); 

    } 
    datareader.Close(); 
相關問題