1. I have a grid control on page and I have use templatefield tag . In Edittemplate and in Itemtemplate I have Command Button name as Edid and Cancel. When I click on those button for first time I am not getting anything. But for second click it is giving me JSScript Error as follow:
Microsoft JScript runtime error: 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.
2. I have that same grid with autopaging property true. Here also for first click I am not getting anything. But for second click it is throwing me JSScript Error as below: GridView Fired PageIndexChangingEvent which was not handle.
I tried adding that event with no code Inside. Srill No result.
SOLUTION 1:
Bind the Gridview from view state after the post back occurs on the page. This will remove the error 1 listed below.
For 2nd error bind the Gridview with data source as shown below in the PageIndexChanging event
protected void GridView1_ (object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
bindGridView(); //bindgridview will get the data source and bind it again
}
{
GridView1.PageIndex = e.NewPageIndex;
bindGridView(); //bindgridview will get the data source and bind it again
}
No comments:
Post a Comment