ASP.NET - paging in child grid - Asked By jyoti yadav on 22-Mar-13 01:12 AM

Hi,
I have nested gridview. in which I have to implement paging in child grid using pager template.

designing code is :-

  <asp:GridView ID="grdOfficeParent" runat="server" HorizontalAlign="Center" BorderWidth="0"
                                  BorderColor="#0E6794" AutoGenerateColumns="False" GridLines="None" CellSpacing="1"
                                  HeaderStyle-BackColor="#006699" CellPadding="2" AllowPaging="true" BorderStyle="Outset"
                                  FooterStyle-BackColor="#006699" FooterStyle-CssClass="pagefootersyle" HeaderStyle-CssClass="header"
                                  Width="100%" AllowSorting="false" ShowFooter="true" ShowHeader="true" CssClass="grid-view"
                                  RowStyle-CssClass="normal" AlternatingRowStyle-CssClass="alternate" PagerStyle-CssClass="pagerstyle"
                                  OnRowDataBound="grdOfficeParent_RowDataBound" OnDataBound="grdOfficeParent_DataBound"
                                  OnPageIndexChanging="grdOfficeParent_PageIndexChanging" OnRowCommand="grdOfficeParent_RowCommand">
                                  <Columns>
                                    <asp:TemplateField>
                                      <HeaderTemplate>
                                        <table cellpadding="0" cellspacing="0" width="100%" border="0" style="table-layout: fixed">
                                         
                                          <tr>
                                            <td align="left" width="15%" class="border1px">
                                              RO Name
                                            </td>                                          
                                            <td align="right" width="7%" class="border1px">
                                              IB InScan
                                            </td>
                                            <td align="right" width="9%" class="border1px">
                                              OB InScan
                                            </td>
                                            <td align="right" width="13%" class="border1px">
                                              Branch Manifest
                                            </td>
                                            <td align="right" width="7%" class="border1px">
                                              OFD
                                            </td>
                                            <td align="center" width="15%" class="border1px">
                                              <table border="0" cellpadding="0" cellspacing="0" width="100%">
                                                <tr>
                                                  <td align="right" width="40%" style="border-right: solid 2px white;">
                                                    SDU
                                                  </td>
                                                  <td align="right" width="60%">
                                                    Data Entry
                                                  </td>
                                                </tr>
                                              </table>
                                            </td>
                                            <td align="right" width="10%" class="border1px">
                                              Undelivered
                                            </td>
                                            <td align="right" width="7%" class="border1px">
                                              RTO
                                            </td>
                                            <td align="right" width="7%" class="border1px">
                                              MB
                                            </td>
                                            <td align="right" width="8%" class="border1px">
                                              GatePass
                                            </td>
                                          </tr>
                                        </table>
                                      </HeaderTemplate>
                                      <ItemTemplate>
                                        <table cellpadding="0" style="table-layout: fixed" cellspacing="0" width="100%" border="0">
                                          <tr>
                                            <td width="15%" align="left" class="border1px">
                                              <asp:Label ID="lblShowDetail" runat="server" ForeColor="Blue"></asp:Label>
                                              <asp:LinkButton ID="lnkbtnRONAME" runat="server" OnClick="lnkbtnRONAME_Click" Text='<%# Eval("RO Name") %>'></asp:LinkButton>
                                            </td>
                                            <%--<td width="22%" align="left"  >
                                                <asp:Label ID="lblOfficeName" runat="server" Text='<%# Eval("Office Name") %>'></asp:Label>
                                              </td>--%>
                                            <td align="right" width="7%" class="border1px">
                                              <%# Eval("IB INSCAN")%>
                                            </td>
                                            <td align="right" width="9%" class="border1px">
                                              <%# Eval("OB INSCAN")%>
                                            </td>
                                            <td align="right" width="13%" class="border1px">
                                              <%# Eval("BRANCH MANIFEST")%>
                                            </td>
                                            <td align="right" width="7%" class="border1px">
                                              <%# Eval("OFD")%>
                                            </td>
                                            <td align="center" width="15%" class="border1px">
                                              <table border="0" cellpadding="0" cellspacing="0" width="100%">
                                                <tr>
                                                  <td align="right" width="40%">
                                                    <%# Eval("SDU")%>
                                                  </td>
                                                  <td align="right" width="60%">
                                                    <%# Eval("Data Entry")%>
                                                  </td>
                                                </tr>
                                              </table>
                                            </td>
                                            <td align="right" width="10%" class="border1px">
                                              <%# Eval("UNDELIVERED")%>
                                            </td>
                                            <td align="right" width="7%" class="border1px">
                                              <%# Eval("RTO")%>
                                            </td>
                                            <td align="right" width="7%" class="border1px">
                                              <%# Eval("MB")%>
                                            </td>
                                            <td align="right" width="8%" class="border1px">
                                              <%# Eval("GATEPASS")%>
                                            </td>
                                          </tr>
                                              <asp:Panel ID="Panel2" runat="server" Width="100%" Style="padding-bottom: 15px;">
                                                <asp:GridView ID="grdUserChild" runat="server" AutoGenerateColumns="False" AllowSorting="True"
                                                  AllowPaging="true" Width="110%" CellPadding="0" CellSpacing="0" CssClass="grid-view"
                                                  HeaderStyle-CssClass="header" RowStyle-CssClass="normal" AlternatingRowStyle-CssClass="alternate"
                                                  GridLines="none" BorderWidth="0px" PagerStyle-CssClass="pagerstyle" OnDataBound="grdUserChild_DataBound"
                                                  OnPageIndexChanging="grdUserChild_PageIndexChanging" OnRowCommand="grdUserChild_RowCommand">
                                                  <Columns>
                                                    <asp:TemplateField>
                                                      <HeaderTemplate>
                                                        <table cellpadding="0" cellspacing="0" width="100%" style="table-layout: fixed" border="0">
                                                         
                                                          <tr>
                                                            <td align="left" width="3%" class="border1px">
                                                              SL#
                                                            </td>
                                                            <td align="left" width="21%" class="border1px">
                                                              Operator Name
                                                            </td>
                                                            <td align="right" width="7%" class="border1px">
                                                              Date
                                                            </td>
                                                            <td align="right" width="9%" class="border1px">
                                                              IB InScan
                                                            </td>
                                                            <td align="right" width="9%" class="border1px">
                                                              OB InScan
                                                            </td>
                                                            <td align="right" width="13%" class="border1px">
                                                              Branch Manifest
                                                            </td>
                                                            <td align="right" width="5%" class="border1px">
                                                              OFD
                                                            </td>
                                                            <td align="center" width="14%" class="border1px">
                                                              <table border="0" cellpadding="0" cellspacing="0" width="100%">
                                                                <tr>
                                                                  <td align="right" width="35%" style="border-right: solid 2px #ffffff;">
                                                                    SDU
                                                                  </td>
                                                                  <td align="right" width="65%">
                                                                    Data Entry
                                                                  </td>
                                                                </tr>
                                                              </table>
                                                            </td>
                                                            <td align="right" width="10%" class="border1px">
                                                              Undelivered
                                                            </td>
                                                            <td align="right" width="5%" class="border1px">
                                                              RTO
                                                            </td>
                                                            <td align="right" width="5%" class="border1px">
                                                              MB
                                                            </td>
                                                            <td align="right" width="9%" class="border1px">
                                                              GatePass
                                                            </td>
                                                          </tr>
                                                        </table>
                                                      </HeaderTemplate>
                                                      <ItemTemplate>
                                                        <table cellpadding="0" cellspacing="0" width="100%" border="0" style="table-layout: fixed;">
                                                          <tr>
                                                            <td width="3%" align="left" class="border1px">
                                                              <%# Container.DataItemIndex + 1 %>
                                                            </td>
                                                            <td width="21%" align="left" class="border1px">
                                                              <%# Eval("Operator Name") %>
                                                            </td>
                                                            <td width="7%" align="right" class="border1px">
                                                              <%# Eval("DATE")%>
                                                            </td>
                                                            <td align="right" width="9%" class="border1px">
                                                              <%# Eval("IB INSCAN")%>
                                                            </td>
                                                            <td align="right" width="9%" class="border1px">
                                                              <%# Eval("OB INSCAN")%>
                                                            </td>
                                                            <td align="right" width="13%" class="border1px">
                                                              <%# Eval("BRANCH MANIFEST")%>
                                                            </td>
                                                            <td align="right" width="5%" class="border1px">
                                                              <%# Eval("OFD")%>
                                                            </td>
                                                            <td align="center" width="14%" class="border1px">
                                                              <table border="0" cellpadding="0" cellspacing="0" width="100%">
                                                                <tr>
                                                                  <td align="right" width="30%">
                                                                    <%# Eval("SDU")%>
                                                                  </td>
                                                                  <td align="right" width="70%">
                                                                    <%# Eval("Data Entry")%>
                                                                  </td>
                                                                </tr>
                                                              </table>
                                                            </td>
                                                            <td align="right" width="10%" class="border1px">
                                                              <%# Eval("UNDELIVERED")%>
                                                            </td>
                                                            <td align="right" width="5%" class="border1px">
                                                              <%# Eval("RTO")%>
                                                            </td>
                                                            <td align="right" width="5%" class="border1px">
                                                              <%# Eval("MB")%>
                                                            </td>
                                                            <td align="right" width="9%" class="border1px">
                                                              <%# Eval("GATEPASS")%>
                                                            </td>
                                                          </tr>
                                                        </table>
                                                      </ItemTemplate>
                                                    </asp:TemplateField>
                                                  </Columns>
                                                  <PagerTemplate>
                                                    <table width="100%">
                                                      <tr>
                                                        <td align="left" width="60%">
                                                          <asp:LinkButton ID="btnFirst" runat="server" Text="First" CommandArgument="First"
                                                            ForeColor="White"></asp:LinkButton>&nbsp;&nbsp;
                                                          <asp:LinkButton ID="btnPrevious" runat="server" Text="Prev" CommandArgument="Prev"
                                                            ForeColor="White"></asp:LinkButton>&nbsp;&nbsp;
                                                          <asp:TextBox ID="txtPagingUser" Text="1" runat="server" AutoPostBack="true" MaxLength="6"
                                                            CssClass="txtboxSmall" Width="20px" OnTextChanged="txtPagingUser_TextChanged" onfocus="this.select()"></asp:TextBox>
                                                          <AjaxTools:FilteredTextBoxExtender ID="filtertxtPagingUser" runat="server" TargetControlID="txtPagingUser"
                                                            FilterType="Numbers">
                                                          </AjaxTools:FilteredTextBoxExtender>
                                                          &nbsp;&nbsp;
                                                          <asp:LinkButton ID="btnNext" runat="server" Text="Next" CommandArgument="Next" ForeColor="White"></asp:LinkButton>&nbsp;&nbsp;
                                                          <asp:LinkButton ID="btnLast" runat="server" Text="Last" CommandArgument="Last" ForeColor="White"></asp:LinkButton>
                                                        </td>
                                                        <td align="right">
                                                          <asp:Label ID="CurrentPageLabel" runat="server"></asp:Label>
                                                        </td>
                                                      </tr>
                                                    </table>
                                                  </PagerTemplate>
                                                  <EmptyDataRowStyle ForeColor="White" />
                                                </asp:GridView>
                                              </asp:Panel>
                                            </td>
                                          </tr>
                                        </table>                                  
                                      </ItemTemplate>
                                      <FooterTemplate>
                                        <table border="0" cellpadding="0" cellspacing="0" width="100%" style="table-layout: fixed;">
                                          <tr>
                                            <td align="right" width="15%">
                                              GRAND TOTAL :
                                            </td>
                                            <td align="right" width="7%">
                                              <asp:Label ID="lblIBInScan" runat="server"></asp:Label>
                                            </td>
                                            <td align="right" width="9%">
                                              <asp:Label ID="lblOBInScan" runat="server"></asp:Label>
                                            </td>
                                            <td align="right" width="13%">
                                              <asp:Label ID="lblBranchManifest" runat="server"></asp:Label>
                                            </td>
                                            <td align="right" width="7%">
                                              <asp:Label ID="lblOFD" runat="server"></asp:Label>
                                            </td>
                                            <td align="center" width="15%">
                                              <table border="0" cellpadding="0" cellspacing="0" width="100%">
                                                <tr>
                                                  <td align="right" width="40%">
                                                    <asp:Label ID="lblSDU" runat="server"></asp:Label>
                                                  </td>
                                                  <td align="right" width="60%">
                                                    <asp:Label ID="lblDataEntry" runat="server"></asp:Label>
                                                  </td>
                                                </tr>
                                              </table>
                                            </td>
                                            <td align="right" width="10%">
                                              <asp:Label ID="lblUndelivered" runat="server"></asp:Label>
                                            </td>
                                            <td align="right" width="7%">
                                              <asp:Label ID="lblRTO" runat="server"></asp:Label>
                                            </td>
                                            <td align="right" width="7%">
                                              <asp:Label ID="lblMB" runat="server"></asp:Label>
                                            </td>
                                            <td align="right" width="8%">
                                              <asp:Label ID="lblGatePass" runat="server"></asp:Label>
                                            </td>
                                          </tr>
                                        </table>
                                      </FooterTemplate>
                                    </asp:TemplateField>
                                  </Columns>
                                  <PagerTemplate>
                                    <table width="100%">
                                      <tr>
                                        <td align="left" width="60%">
                                          <asp:LinkButton ID="btnFirst" runat="server" Text="First" CommandArgument="First"
                                            ForeColor="White"></asp:LinkButton>&nbsp;&nbsp;
                                          <asp:LinkButton ID="btnPrevious" runat="server" Text="Prev" CommandArgument="Prev"
                                            ForeColor="White"></asp:LinkButton>&nbsp;&nbsp;
                                          <asp:TextBox ID="txtPaging" Text="1" runat="server" AutoPostBack="true" MaxLength="6"
                                            CssClass="txtboxSmall" Width="20px" OnTextChanged="txtPaging_TextChanged" onfocus="this.select()"></asp:TextBox>
                                          <AjaxTools:FilteredTextBoxExtender ID="filtertxtPaging" runat="server" TargetControlID="txtPaging"
                                            FilterType="Numbers">
                                          </AjaxTools:FilteredTextBoxExtender>
                                          &nbsp;&nbsp;
                                          <asp:LinkButton ID="btnNext" runat="server" Text="Next" CommandArgument="Next" ForeColor="White"></asp:LinkButton>&nbsp;&nbsp;
                                          <asp:LinkButton ID="btnLast" runat="server" Text="Last" CommandArgument="Last" ForeColor="White"></asp:LinkButton>
                                        </td>
                                        <td align="right">
                                          <asp:Label ID="CurrentPageLabel" runat="server"></asp:Label>
                                        </td>
                                      </tr>
                                    </table>
                                  </PagerTemplate>                             
                                </asp:GridView>


Actually, I got error on txtPagingUser onclick event. I am unable to find child grid properties on that event, and because of the i cant get BottomPagerRow properites of gridview. So, how can I do this?