Get Row Count from SqlDataSource after Filtering
Select from the sqldatasource and convert the output to a dataview, then place the same filter you are using, and get the count. Remember to place this code in the databound event.
protected void gvCurLookup_DataBound(Object sender, System.EventArgs e)
{
System.Data.DataView dv = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
dv.RowFilter = SqlDataSource1.FilterExpression;
int RowCount = dv.Count;
if (dv.Count > 0)
{
this.lblMsg.Text = dv.Count + " Books...";
}
}
ref
protected void gvCurLookup_DataBound(Object sender, System.EventArgs e)
{
System.Data.DataView dv = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
dv.RowFilter = SqlDataSource1.FilterExpression;
int RowCount = dv.Count;
if (dv.Count > 0)
{
this.lblMsg.Text = dv.Count + " Books...";
}
}
ref
Comments
Post a Comment