It is a strange problem. I am setting the pagesize of gridview in dropdownlist selectedindexchanged which is i gridview pager template. Here is my html source
<PagerTemplate>
<div class="grid-footer">
<div class="gridfooter_size"> <asp:DropDownList ID="pageSize2" runat="server" AutoPostBack="true"
onselectedindexchanged="pageSize2_SelectedIndexChanged">
<asp:ListItem Value="10" Selected="True">10</asp:ListItem>
<asp:ListItem Value="25">25</asp:ListItem>
<asp:ListItem Value="50">50</asp:ListItem>
<asp:ListItem Value="100">100</asp:ListItem>
</asp:DropDownList>
</div>
<div class="gridfooter_info">
<asp:Label ID="lblSummary" runat="server"></asp:Label>
</div>
<div class="gridfooter_paginate">
<asp:LinkButton ID="lnkFirstbnt" runat="server" CommandName="Page" CssClass="pagerclass-nxt"
CausesValidation="false" CommandArgument="First">First</asp:LinkButton>
<asp:LinkButton ID="lnkPrevbnt" runat="server" CommandName="Page" CssClass="pagerclass-prev"
CausesValidation="false" CommandArgument="Prev">Previous</asp:LinkButton>
<asp:Label ID="CurrentPage" CssClass="pagerclass-number" Visible="false" runat="server"
Text="Label"></asp:Label>
<asp:LinkButton ID="lnkNextbnt" runat="server" CommandName="Page" CssClass="pagerclass-next"
CausesValidation="false" CommandArgument="Next">Next</asp:LinkButton>
<asp:LinkButton ID="lnkLastbnt" runat="server" CommandName="Page" CssClass="pagerclass-last"
CausesValidation="false" CommandArgument="Last">Last</asp:LinkButton>
</div>
</div>
</PagerTemplate>
Here is my code behind
Protected Sub pageSize2_SelectedIndexChanged(sender As Object, e As System.EventArgs)
Dim gvr2 As GridViewRow = GridView2.BottomPagerRow
Dim ddPageSize2 As DropDownList = DirectCast(gvr2.Cells(0).FindControl("pageSize2"), DropDownList)
GridView2.PageSize = Convert.ToInt32(ddPageSize2.SelectedValue)
Call GetDataTables2()
End Sub
When post back is occured the pageSize2_SelectedIndexChanged
event is firing for all the selectd values of dropdownlist, but the page is not rendering. It is jumping from the pageSize2_SelectedIndexChanged event Call GetDataTables2()
method. If the dropdownlist selectd value is 10, then the page is rendering, it strange. What might be the problem, Please suggest solution
The problem is, I am using two gridviews in the same update panel. And those two gridviews having the controsl with same IDs under the templates of two gridviews. This might be a bug in visual studio. It did not tell me any compile time exception and not even in runtime until I remove the updatepanel. I ahve changed the control IDs. Now it is working fine.