{"id":1946,"date":"2022-08-30T15:20:46","date_gmt":"2022-08-30T15:20:46","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/12\/05\/aspxgridview-page-works-for-some-users-not-for-others-webform-model-using-c-asp-sql-express-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:20:46","modified_gmt":"2022-08-30T15:20:46","slug":"aspxgridview-page-works-for-some-users-not-for-others-webform-model-using-c-asp-sql-express-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/aspxgridview-page-works-for-some-users-not-for-others-webform-model-using-c-asp-sql-express-collection-of-common-programming-errors\/","title":{"rendered":"ASPxGridView page works for some users, not for others. WebForm model using C#, ASP, SQL Express-Collection of common programming errors"},"content":{"rendered":"<p>I am pretty new to this, so please bare with me. 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<\/p>\n<pre><code> 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 &gt; 0) AND (CONVERT (VARCHAR(19), Start, 120) &gt;= @StartDate) AND (CONVERT (VARCHAR(10), Start, 120) &lt;= @EndDate) order by Start Desc\"&gt;\n<\/code><\/pre>\n<p>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:<\/p>\n<blockquote>\n<p>A field or property with name &#8216;PartCycle&#8217; 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.<\/p>\n<p>Exception Details: System.Web.HttpException: A field or property with name &#8216;PartCycle&#8217; 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.<\/p>\n<p>Source Error:<\/p>\n<p>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.<\/p>\n<p>Stack Trace:<\/p>\n<p>[HttpException (0x80004005): A field or property with name &#8216;PartCycle&#8217; 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<\/p>\n<\/blockquote>\n<p>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.<\/p>\n<p>Thank you for any light you can shed.<\/p>\n<p>-Ben<\/p>\n<ol>\n<li>\n<p>Its because ASPxGridView Caches the Columns.<\/p>\n<p>In your case, your datasource is dynamic i.e. different for different users.<\/p>\n<p>Make sure to Clear the Columns before binding ASPxGridView.<\/p>\n<p>To Clear the Columns:<\/p>\n<pre><code>agvObject.Columns.Clear();\n<\/code><\/pre>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-12-05 16:29:39. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I am pretty new to this, so please bare with me. 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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1946","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1946","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1946"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1946\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1946"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1946"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1946"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}