Last post Nov 11, 2015 02:06 AM by Candice Zhou
Nov 10, 2015 10:37 AM|Chad.Marshall|LINK
I'm trying to support an application with very strange behavior. We've implemented a custom paging solution using a GridView control from ASP.NET. This application has been deployed to numerous locations, under both .NET 2/3.5 and now .NET 4, with no issues
spanning several years. All the sudden I have precisely two environments where the GridView control renders with no rows displayed, only headers, despite having rows in the data source. One environment is a customer production box, the other is my dev environment
but only when hosted from WebDev (have not tried IISExpress). Other development boxes seem fine, just not mine.
For my local dev box I've traced all the code I can and cannot make sense where the rows disappear. If I copy my solution code manually to a separate server and host under IIS then the grid renders fine. The only thing I've discovered so far is that if
I disable paging on the GridView control then my rows appear fine.
Does anyone have thoughts on what I should be looking for? .NET patches? 3rd party components? The customer claims this issue happened right after installing windows updates a few months ago, but still has not provided a list of what updates.
Here's a code snippet of how the data source is assigned to the GridView:
public void FillGridView(GridView grdControl, ObjectDataSource ods)
ods.EnablePaging = grdControl.AllowPaging;
ods.TypeName = "OurCustomClass.SourceTableAdapter";
ods.SelectMethod = "GetData";
ods.SelectCountMethod = "VirtualRowCount";
ods.StartRowIndexParameterName = "startRow";
ods.MaximumRowsParameterName = "maxRows";
ods.EnableViewState = false;
ods.ObjectCreating += new ObjectDataSourceObjectEventHandler(ods_ObjectCreating);
grdControl.DataSourceID = ods.ID;
Where the ods_ObjectCreating method just sets the object instance to a new "SourceTableAdapter", which is a place holder for a DataTable and the events/parameters called out above.
I started creating subscriptions to all of the events of ObjectDataSource and eventually came up with this solution/workaround:
void ods_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
if (e.Arguments.TotalRowCount < 1 && _srcTable != null && _srcTable.Rows.Count > 0)
//Set maximum rows to the current count of the source table
//as the source table represents the current page.
e.Arguments.MaximumRows = _srcTable.Rows.Count;
//Set total row count to virtual row count, which is the
//actual un-paged size of the custom data source.
e.Arguments.TotalRowCount = _virtualRowCount;
The problem I discovered here was that while the data source had data at the time of 'Selecting', the row counts were wrong. TotalRowCount was -1 and MaximumRows was 0. So overriding those to be my known values for the custom paging solution corrects the
issue. I'm just still very confused why this was needed since saying the code works fine in hundreds of environments wouldn't be an exaggeration.
Nov 11, 2015 02:06 AM|Candice Zhou|LINK
I think the most likely reason is the latest Windows Update/Patch.
I suggest you listing the update packages on two PCs. One can display data normally, another cannot. Then, the PC that can't normal work should uninstall the new update packages, you could make sure it will be whether cause of Windows Update. If it is cause
of Windows Update, you could report to Microsoft.