我有 aspx gridview,我有两个从后面的代码创建的按钮。它们是编辑和更新,它们的命令分别是“编辑”和“更新”。当我单击编辑按钮时,它也会根据代码启用(单击编辑按钮启用行中复选框的编号)更新按钮。虽然实际上它不起作用并且它给出了如下错误:
Uncaught Sys.WebForms.PageRequestManagerServerErrorException: Sys.WebForms.PageRequestManagerServerErrorException: Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request. ScriptResource.axd?d=s633GAD3X_M-LlZYiT3qBN0z6qIwAPEBIp-UIaJwC1RmW46ky4uU_K…FVxRGlhX1aNlsf8k9x5vWwmLMiniFjzCpYiBd1nZ4CsPRcFgOOZfIhN5YF0&t=6119e399:237
Error$create ScriptResource.axd?d=s633GAD3X_M-LlZYiT3qBN0z6qIwAPEBIp-UIaJwC1RmW46ky4uU_K…FVxRGlhX1aNlsf8k9x5vWwmLMiniFjzCpYiBd1nZ4CsPRcFgOOZfIhN5YF0&t=6119e399:237
Sys$WebForms$PageRequestManager$_createPageRequestManagerServerError ScriptResource.axd?d=7CCl932sdoNYgGI8lOxtB8kESr24em-vtPyWNc_v1_wD6b2GgTVWjP…QcN8ofM_7MSrJt5JPbNycIyF7ZMnid435yQKsqw0E4wzsq_yDDUHNjPqpn0&t=6119e399:656
Sys$WebForms$PageRequestManager$_parseDelta ScriptResource.axd?d=7CCl932sdoNYgGI8lOxtB8kESr24em-vtPyWNc_v1_wD6b2GgTVWjP…cN8ofM_7MSrJt5JPbNycIyF7ZMnid435yQKsqw0E4wzsq_yDDUHNjPqpn0&t=6119e399:1534
Sys$WebForms$PageRequestManager$_onFormSubmitCompleted ScriptResource.axd?d=7CCl932sdoNYgGI8lOxtB8kESr24em-vtPyWNc_v1_wD6b2GgTVWjP…cN8ofM_7MSrJt5JPbNycIyF7ZMnid435yQKsqw0E4wzsq_yDDUHNjPqpn0&t=6119e399:1314
(anonymous function) ScriptResource.axd?d=s633GAD3X_M-LlZYiT3qBN0z6qIwAPEBIp-UIaJwC1RmW46ky4uU_K…RFVxRGlhX1aNlsf8k9x5vWwmLMiniFjzCpYiBd1nZ4CsPRcFgOOZfIhN5YF0&t=6119e399:47
(anonymous function) ScriptResource.axd?d=s633GAD3X_M-LlZYiT3qBN0z6qIwAPEBIp-UIaJwC1RmW46ky4uU_K…VxRGlhX1aNlsf8k9x5vWwmLMiniFjzCpYiBd1nZ4CsPRcFgOOZfIhN5YF0&t=6119e399:3484
Sys$Net$WebRequest$completed ScriptResource.axd?d=s633GAD3X_M-LlZYiT3qBN0z6qIwAPEBIp-UIaJwC1RmW46ky4uU_K…VxRGlhX1aNlsf8k9x5vWwmLMiniFjzCpYiBd1nZ4CsPRcFgOOZfIhN5YF0&t=6119e399:6373
Sys$Net$XMLHttpExecutor._onReadyStateChange ScriptResource.axd?d=s633GAD3X_M-LlZYiT3qBN0z6qIwAPEBIp-UIaJwC1RmW46ky4uU_K…VxRGlhX1aNlsf8k9x5vWwmLMiniFjzCpYiBd1nZ4CsPRcFgOOZfIhN5YF0&t=6119e399:5993
应该是什么问题,我该如何解决?
两个按钮
Dim btn2 As New Button()
btn2.ID = "btn2"
btn2.Width = "50"
btn2.Text = "Update"
btn2.CssClass = "AdminPageBtn"
btn2.CommandName = "Update"
btn2.CommandArgument = "Update"
btn2.Enabled = True
'If (nMonth >= intCurrentMonth) And (nYear = intCurrentYear) Then
' btn2.Enabled = True
'End If
e.Row.Cells(e.Row.Cells.Count - 1).Controls.Add(btn2)
Dim btn1 As New Button()
btn1.ID = "btn1"
btn1.Width = "50"
btn1.Text = "Edit"
btn1.CssClass = "AdminPageBtn"
btn1.CommandName = "Edit"
btn1.CommandArgument = "Edit"
btn1.Enabled = True
e.Row.Cells(e.Row.Cells.Count - 1).Controls.Add(btn1)
EDIT 按钮的问题原因:假设