M
Matt House
I have a DataTable that I have filled using a SqlDataReader (it holds
approximately 170 rows) used to populate a DataGrid inside of an ASP.NET
application. The DataGrid's footer contains a control to hold the sum of a
dollar amount of the displayed rows. At some point, a user may apply a
filter on the data to view only a subset of the data. I create a new
DataView, set the RowFilter property, and use that as the datasource for the
DataGrid. It seems the DataView knows how many rows meet the filter
criteria, but it is unable to display the correct rows. That is, for a
given filter, the DataView knows that there may be only N records, but it
always returns the first N from the unfiltered 170 row set.
How do I access the rows of a DataView that meet the RowFilter condition?
I've include my code below.
Thanks,
Matt
public void OnItemCreated(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e) {
..
DataView dv = new DataView(dtInfo);
dv.RowFilter = (string)ViewState[this.ID + "wccDG_strGridFilter"];
dv.RowStateFilter = DataViewRowState.OriginalRows;
for (int i=0;i<dv.Count;i++) //dv.Count holds the correct
(filtered) value
{
if (dv.Table.Rows.IsNull(5) )
dFunding += 0.0M;
else
dFunding += Convert.ToDecimal(
dv.Table.Rows.ItemArray.GetValue(5) );
}
lblFunding.Text = dFunding.ToString("c0") + " Funding";
..
approximately 170 rows) used to populate a DataGrid inside of an ASP.NET
application. The DataGrid's footer contains a control to hold the sum of a
dollar amount of the displayed rows. At some point, a user may apply a
filter on the data to view only a subset of the data. I create a new
DataView, set the RowFilter property, and use that as the datasource for the
DataGrid. It seems the DataView knows how many rows meet the filter
criteria, but it is unable to display the correct rows. That is, for a
given filter, the DataView knows that there may be only N records, but it
always returns the first N from the unfiltered 170 row set.
How do I access the rows of a DataView that meet the RowFilter condition?
I've include my code below.
Thanks,
Matt
public void OnItemCreated(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e) {
..
DataView dv = new DataView(dtInfo);
dv.RowFilter = (string)ViewState[this.ID + "wccDG_strGridFilter"];
dv.RowStateFilter = DataViewRowState.OriginalRows;
for (int i=0;i<dv.Count;i++) //dv.Count holds the correct
(filtered) value
{
if (dv.Table.Rows.IsNull(5) )
dFunding += 0.0M;
else
dFunding += Convert.ToDecimal(
dv.Table.Rows.ItemArray.GetValue(5) );
}
lblFunding.Text = dFunding.ToString("c0") + " Funding";
..