ASPxGridView page works for some users, not for others. WebForm model using C#, ASP, SQL Express

1

I am debugging a website built on the WebForms model, using ASP, C# as codebehind, and SQL Express 2008 R2. I am trying to debug a page that uses an ASPxGridView, which is populated from the .aspx file, and the dataset is uses is created there as well. The data is selected using

 SelectCommand="SELECT MachineID, ProgramNo, (CONVERT (VARCHAR(19), Start, 120)) as Start,(CONVERT (VARCHAR(12), Stop,114)) as StopTime, WorkCount, PartCount as TotalWorkCount,(CONVERT (VARCHAR(12), Stop-start,114)) as PartCycle  FROM Program WHERE (MachineID = @MachineID) AND (WorkCount > 0) AND (CONVERT (VARCHAR(19), Start, 120) >= @StartDate) AND (CONVERT (VARCHAR(10), Start, 120) <= @EndDate) order by Start Desc">

The problem is that most users can login and the page works perfectly, but a few users see the following error in the web browser:

A field or property with name 'PartCycle' was not found in the selected data source. Possible causes of this error may be the following: an incorrect or case-insensitive spelling of the grid column name; assigning a wrong or not properly initialized data source to the grid. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: A field or property with name 'PartCycle' was not found in the selected data source. Possible causes of this error may be the following: an incorrect or case-insensitive spelling of the grid column name; assigning a wrong or not properly initialized data source to the grid.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[HttpException (0x80004005): A field or property with name 'PartCycle' was not found in the selected data source. Possible causes of this error may be the following: an incorrect or case-insensitive spelling of the grid column name; assigning a wrong or not properly initialized data source to the grid.] DevExpress.Web.Data.WebDataControllerProvider.GetRowValueByControllerRow(Int32 controllerRow, String fieldName, Boolean isDesignTime) +300 DevExpress.Web.Data.WebDataControllerProvider.GetRowValue(Int32 visibleIndex, String fieldName, Boolean isDesignTime) +203 DevExpress.Web.Data.WebDataProxy.GetRowValue(Int32 visibleIndex, String fieldName) +77

As you can see, PartCycle is not a column in the tables, but is used as an alias for (CONVERT (VARCHAR(12), Stop-start,114)). To put a twist in the plot, I can view the problem data just fine when I am logged into the site as an Administrator. The users who see this error have various ASPNET Roles, but each have access to the data in the tables selected.

webforms
devexpress
aspxgridview
asked on Stack Overflow Dec 1, 2012 by user1867843 • edited Sep 6, 2019 by Flimzy

1 Answer

2

Its because ASPxGridView Caches the Columns.

In your case, your datasource is dynamic i.e. different for different users.

Make sure to Clear the Columns before binding ASPxGridView.

To Clear the Columns:

agvObject.Columns.Clear();
answered on Stack Overflow Feb 27, 2013 by Kumar Lachhani

User contributions licensed under CC BY-SA 3.0