Last post Oct 10, 2017 08:12 AM by Cathy Zou
Oct 09, 2017 11:44 AM|Yeoman|LINK
I have a ListView, which is filled by a SqlDataSource in combination with a FilterExpression.
How can I retrieve the total number of records in the ListView, including all records in all pages of a connected DataPager?
Oct 10, 2017 08:12 AM|Cathy Zou|LINK
you can simply apply the FilterExpression you have for the SQLDataSource to the DataView. Then, a Count on the DataView will return the rows which match your FilterExpression:
protected void SqlDataSource1_Selected(object sender, SqlDataSourceStatusEventArgs e)
DataView dvsqllist = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
dvsqllist.RowFilter = SqlDataSource1.FilterExpression;
int n = dvsqllist.Count;
Or you can use ListView.PageCount * ListView.Items.Count