2012-01-02 64 views

回答

0

創建一個數據集來綁定gridview中的數據。只有您擁有數據集,您可以根據您傳遞的參數(如代碼行)獲取行數。 例如,

DataSet FillGvds = new DataSet(); 
paramFillGvds = "param1"; 
GetFillGvds();// Assuming you have created the method to fill the dataset. 
if(FillGvds != null) 
{ 
if(FillGvds.Tables[0].Rows.Count > 0) 
{ 
    GridView1.Datasource = FillGvds; 
    GridView1.DataBind(); 
    label1.Text = Convert.ToString(FillGvds.Tables[0].Rows.Count); 
} 
} 
+0

謝謝,但我只需要使用sqldatasource。請告訴我sqldatsoure的方式。 – Uneverno 2012-01-02 09:21:04

0

GridView已經啓用了分頁?如果沒有,那麼數據綁定就可以得到後的行數從:

this.YourGridView.Rows.Count 

如果這就是你要找沒有什麼,它會幫助,如果你可以張貼一些代碼來顯示你試過什麼。

相關問題