Reputation: 49
i need to get the count of rows in sqldatasoure which has one select parameter and gets from a label control's text from gridview selected value. how to get rows count of sqldatasource in this context where the select param is passed in selected changed event of gridview.
Upvotes: 0
Views: 2778
Reputation: 18654
Does your GridView
have paging enabled? If not, then after databinding you can get the row count from:
this.YourGridView.Rows.Count
If that's not what you're looking for, it would help if you could post some code to show what you've tried.
Upvotes: 0
Reputation: 839
Create a dataset to bind data in the gridview. Only you have the dataset, you can get the count of rows based on the parameter you pass with like line of code. For instance,
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);
}
}
Upvotes: 0