My web app is using user controls and a master page. I have over 10 user controls with the gridview and all have an edit command field. I just added a new user control and created a new data source for it. I used existing code for the HTML itself from an
existing one. When I click the edit button on the row, it takes me to edit mode, I then click the save button and I get the: even though the database is updated.
Error: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500
however, when I click the cancel button, the grid refreshes and I can see the updated data. I checked everything in the HTML, code behind, etc. what would cause this user control to get this error when clicking save, but it works when clicking the cancel
and the data is being updated.
One thing I did try is if I show all columns in the grid, I can inline update with no issues, however, I only want 3 of the data columns shown in the grid. I don't want to show last updated by or last updated columns, if these are visible it works ,if they
are not in the grid, I get the error above. With them not visible in the grid, I can still see the values when I step through the update code
We can only assume without code that reproduces the actual exception. My assumption is the visibility property to false which stops the inline inputs from being sent to the browser. The missing input values causes the exception.
Have you tried setting a break point and single stepping through the code? Perhaps add a try...catch block to catch the error.
I have 10 other grids within the app that only show a few data values and lastmodiedby isn't a value being shown to the user via the GUI and all work as expected:
Yes, I set a break point and the data is being updated but the page/grid isn't refreshing, however, if I click cancel, it refreshes the grid and shows the updated data.
this is the code for the grid for the usercontrol I'm having the issue with, this code is also used within other user controls and works as expected
The community needs enough code to reproduce the 500 error. Otherwise; there's not much we can do but guess which is not productive.
Is there anyway you can provide sample code that reproduces this issue? Or the methods that fetch or update along with the event handler? Have you tried wrapping code in a try catch so you are not throwing a 500 error to the UI?
When you set the break point, which line of code caused the exception?
That's the code, it's the grid with the data source. I dragged and dropped the gridview to the page, the object data source to the page connected the 2 and removed columns that don't need to be viewed in the GUI
The GetData is pulling the data and the update is well, updating via SQL.
Again, if I show the LastUpdated and LastUpdatedBy in the grid, it works 100%, If I remove them from the grid, I get the 500 error. I stepped through the code and the values are being passed in both scenarios.
The server side exception message should be written to the Windows event log. It could help to better understand what happens. Your intent is to provide values programmatically rather than from the UI ?
Exception information:
Exception type: TargetInvocationException
Exception message: Exception has been thrown by the target of an invocation.
Request information:
Request URL: http://localhost:49573/admin.aspx
Request path: /admin.aspx
User host address: ::1
User:
Is authenticated: False
Authentication Type:
Thread information:
Thread ID: 11
Is impersonating: False
Stack trace: at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Web.UI.WebControls.ObjectDataSourceView.InvokeMethod(ObjectDataSourceMethod method, Boolean disposeInstance, Object& instance)
at System.Web.UI.WebControls.ObjectDataSourceView.InvokeMethod(ObjectDataSourceMethod method)
at System.Web.UI.WebControls.ObjectDataSourceView.ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues)
at System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCallback callback)
at System.Web.UI.WebControls.GridView.HandleUpdate(GridViewRow row, Int32 rowIndex, Boolean causesValidation)
at System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup)
at System.Web.UI.WebControls.GridView.OnBubbleEvent(Object source, EventArgs e)
at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
at System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source, EventArgs e)
at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
at System.Web.UI.WebControls.ImageButton.OnCommand(CommandEventArgs e)
at System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
and the update logic is this (which is the same as the other 10 working grids/usercontrols within the app, only the table and columns change), and as I mentioned, if I click cancel, the data is updated and the grid refreshes and this works IF the lastupdated
and lastupdatedby are visible in the grid in the gui, I can't even set them to visible=false, I get the 500 error with that as well.
And [rows] returns 1, so a row is being returned in the update, this is on a user control being used within a master page and the app has 10 other usercontrols using the same code and all work just fine (different tables obviously)
if I click cancel, the data is updated and the grid refreshes and this works IF the lastupdated and lastupdatedby are visible in the grid in the gui, I can't even set them to visible=false, I get the 500 error with that as well.
As stated above, the framework does not render the HTML when the Visible property is set to false. How are you populating the CarSales argument?
Try setting a break point in the Update method and verify the LastUpdated and LastUpdatedBy properties are populated.
I did a work around for now by just adding those 2 columns and hiding the header and making the font white so it wouldn't appear in the grid. As stated before the columns are being populated in when updating, however, it kicks out the 500 error.
I'm done with it for now. I'll loop back to it at a later time.
A bit weird it shows a problem when calling Update but doesn't show which problem happened. Would have to check that.
My guess is that when you don't include this column, item.LastUpdated is populated with the default date (1/1/0001) which is out of range for SQL Server causing then an exception.
A quick fix could be to assign yourself a value such as DateTime.Now or UtcNow to replace the default 1//1/1 value.
A bit weird it shows a problem when calling Update but doesn't show which problem happened. Would have to check that.
My guess is that when you don't include this column, item.LastUpdated is populated with the default date (1/1/0001) which is out of range for SQL Server causing then an exception.
A quick fix could be to assign yourself a value such as DateTime.Now or UtcNow to replace the default 1//1/1 value.
I know, and if I click the "cancel" when updating, it works, data is updated, grid refreshes. In the update code I have it as:
this is called when the in the onRowUpdated method within the gridview. When I step through it, I can see today's date and the user id
Member
15 Points
278 Posts
500 error when inline updating
May 21, 2019 02:33 PM|uid829402|LINK
My web app is using user controls and a master page. I have over 10 user controls with the gridview and all have an edit command field. I just added a new user control and created a new data source for it. I used existing code for the HTML itself from an existing one. When I click the edit button on the row, it takes me to edit mode, I then click the save button and I get the: even though the database is updated.
Error: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500
however, when I click the cancel button, the grid refreshes and I can see the updated data. I checked everything in the HTML, code behind, etc. what would cause this user control to get this error when clicking save, but it works when clicking the cancel and the data is being updated.
One thing I did try is if I show all columns in the grid, I can inline update with no issues, however, I only want 3 of the data columns shown in the grid. I don't want to show last updated by or last updated columns, if these are visible it works ,if they are not in the grid, I get the error above. With them not visible in the grid, I can still see the values when I step through the update code
At a loss on this one
All-Star
52971 Points
23566 Posts
Re: 500 error when inline updating
May 21, 2019 03:13 PM|mgebhard|LINK
We can only assume without code that reproduces the actual exception. My assumption is the visibility property to false which stops the inline inputs from being sent to the browser. The missing input values causes the exception.
Have you tried setting a break point and single stepping through the code? Perhaps add a try...catch block to catch the error.
Member
15 Points
278 Posts
Re: 500 error when inline updating
May 21, 2019 03:57 PM|uid829402|LINK
I have 10 other grids within the app that only show a few data values and lastmodiedby isn't a value being shown to the user via the GUI and all work as expected:
Yes, I set a break point and the data is being updated but the page/grid isn't refreshing, however, if I click cancel, it refreshes the grid and shows the updated data.
this is the code for the grid for the usercontrol I'm having the issue with, this code is also used within other user controls and works as expected
All-Star
52971 Points
23566 Posts
Re: 500 error when inline updating
May 21, 2019 05:03 PM|mgebhard|LINK
The community needs enough code to reproduce the 500 error. Otherwise; there's not much we can do but guess which is not productive.
Is there anyway you can provide sample code that reproduces this issue? Or the methods that fetch or update along with the event handler? Have you tried wrapping code in a try catch so you are not throwing a 500 error to the UI?
When you set the break point, which line of code caused the exception?
Member
15 Points
278 Posts
Re: 500 error when inline updating
May 21, 2019 05:11 PM|uid829402|LINK
That's the code, it's the grid with the data source. I dragged and dropped the gridview to the page, the object data source to the page connected the 2 and removed columns that don't need to be viewed in the GUI
Contributor
3710 Points
1043 Posts
Re: 500 error when inline updating
May 22, 2019 10:16 AM|Yongqing Yu|LINK
Hi IGotYourDotNet,
According to the code you provided, I can't reproduce the question you described.
The TypeName = "" in this statement, how do you bind GridView to data?
Could you please provide these two methods SelectMethod = "GetData" and UpdateMethod = "Update" in code behind ?
And I want to know what your gridview's outer user controls look like.
I hope you can provide more detailed front-end code and code behind.
If you could post more details information, it will be more easily for us to reproduce the issue and find out the solution.
Best Regards,
YongQing.
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
15 Points
278 Posts
Re: 500 error when inline updating
May 22, 2019 11:55 AM|uid829402|LINK
The GetData is pulling the data and the update is well, updating via SQL.
Again, if I show the LastUpdated and LastUpdatedBy in the grid, it works 100%, If I remove them from the grid, I get the 500 error. I stepped through the code and the values are being passed in both scenarios.
All-Star
48490 Points
18069 Posts
Re: 500 error when inline updating
May 22, 2019 12:06 PM|PatriceSc|LINK
Hi,
The server side exception message should be written to the Windows event log. It could help to better understand what happens. Your intent is to provide values programmatically rather than from the UI ?
Member
15 Points
278 Posts
Re: 500 error when inline updating
May 22, 2019 12:16 PM|uid829402|LINK
The EV shows this:
Exception information:
Exception type: TargetInvocationException
Exception message: Exception has been thrown by the target of an invocation.
Request information:
Request URL: http://localhost:49573/admin.aspx
Request path: /admin.aspx
User host address: ::1
User:
Is authenticated: False
Authentication Type:
Thread information:
Thread ID: 11
Is impersonating: False
Stack trace: at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Web.UI.WebControls.ObjectDataSourceView.InvokeMethod(ObjectDataSourceMethod method, Boolean disposeInstance, Object& instance)
at System.Web.UI.WebControls.ObjectDataSourceView.InvokeMethod(ObjectDataSourceMethod method)
at System.Web.UI.WebControls.ObjectDataSourceView.ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues)
at System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCallback callback)
at System.Web.UI.WebControls.GridView.HandleUpdate(GridViewRow row, Int32 rowIndex, Boolean causesValidation)
at System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup)
at System.Web.UI.WebControls.GridView.OnBubbleEvent(Object source, EventArgs e)
at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
at System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source, EventArgs e)
at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
at System.Web.UI.WebControls.ImageButton.OnCommand(CommandEventArgs e)
at System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
and the update logic is this (which is the same as the other 10 working grids/usercontrols within the app, only the table and columns change), and as I mentioned, if I click cancel, the data is updated and the grid refreshes and this works IF the lastupdated and lastupdatedby are visible in the grid in the gui, I can't even set them to visible=false, I get the 500 error with that as well.
And [rows] returns 1, so a row is being returned in the update, this is on a user control being used within a master page and the app has 10 other usercontrols using the same code and all work just fine (different tables obviously)
All-Star
52971 Points
23566 Posts
Re: 500 error when inline updating
May 22, 2019 01:16 PM|mgebhard|LINK
As stated above, the framework does not render the HTML when the Visible property is set to false. How are you populating the CarSales argument?
Try setting a break point in the Update method and verify the LastUpdated and LastUpdatedBy properties are populated.
Member
15 Points
278 Posts
Re: 500 error when inline updating
May 22, 2019 01:49 PM|uid829402|LINK
I did a work around for now by just adding those 2 columns and hiding the header and making the font white so it wouldn't appear in the grid. As stated before the columns are being populated in when updating, however, it kicks out the 500 error.
I'm done with it for now. I'll loop back to it at a later time.
All-Star
48490 Points
18069 Posts
Re: 500 error when inline updating
May 22, 2019 02:05 PM|PatriceSc|LINK
A bit weird it shows a problem when calling Update but doesn't show which problem happened. Would have to check that.
My guess is that when you don't include this column, item.LastUpdated is populated with the default date (1/1/0001) which is out of range for SQL Server causing then an exception.
A quick fix could be to assign yourself a value such as DateTime.Now or UtcNow to replace the default 1//1/1 value.
Member
15 Points
278 Posts
Re: 500 error when inline updating
May 22, 2019 06:32 PM|uid829402|LINK
I know, and if I click the "cancel" when updating, it works, data is updated, grid refreshes. In the update code I have it as:
this is called when the in the onRowUpdated method within the gridview. When I step through it, I can see today's date and the user id
Contributor
3710 Points
1043 Posts
Re: 500 error when inline updating
May 24, 2019 07:55 AM|Yongqing Yu|LINK
Hi IGotYourDotNet,
According to the code and description you provided , I still have no way to reproduce your question.
Could you please provide all the detailed code for your function? This will help us solve the issue more easierly.
Best Regards,
YongQing.
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.