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


 

Comments

Popular posts from this blog

Asp.net Publishing Broke Site - "App_WebReferences is not allowed because the application is precompiled"

Telerik - Custom Group Footers In RadGrid