0

am using obout Grid and am creating Details Grid i want to find out the current Page Index of Details Grid(child Grid) my Grid are below

<obout:DetailGrid runat="server" ID="GrdCategoryDetails" ForeignKeys="VENDOR_TYPE_LOOKUP_CODE,VENDOR_ID,ORG_ID"
    AllowSorting="false" DataSourceID="vendor_Details" PageSize="10" AllowPaging="true"
    Width="98%" AllowAddingRecords="false" AllowPageSizeSelection="true" AutoGenerateColumns="false"
    ShowCollapsedGroups="false" ShowFooter="true" AllowDataAccessOnServer="true">
    <ScrollingSettings ScrollHeight="250" />
    <Columns>
        <obout:Column DataField="ORG_ID" Visible="false" HeaderText="Org ID" ReadOnly="true"
            Width="0%">
        </obout:Column>
        <obout:Column DataField="VENDOR_ID" Visible="false" HeaderText="Vendor ID" ReadOnly="true"
            Width="0%">
        </obout:Column>
        <obout:Column DataField="VENDOR_TYPE_LOOKUP_CODE" Visible="true" HeaderText="Broker Type"
            ReadOnly="true" Width="33%">
        </obout:Column>
        <obout:Column DataField="OUTSTANDING_AMT" Visible="true" HeaderText="Outstanding Amt"
            HeaderAlign="right" Align="right" ReadOnly="true" Width="33%">
        </obout:Column>
        <obout:Column DataField="OUTSTANDING_REQ_AMT" Visible="true" HeaderText="Outstanding Req Amt"
            HeaderAlign="right" Align="right" Width="33%">
        </obout:Column>
        <%--<obout:Column ID="Column1" AllowEdit="true" HeaderText="Edit" Width="100" runat="server">
        </obout:Column>--%>
    </Columns>
    <DetailGrids>
        <obout:DetailGrid runat="server" ID="GrdvendorDetailsGrid" ForeignKeys="VENDOR_TYPE_LOOKUP_CODE,VENDOR_ID,ORG_ID"
            AutoGenerateColumns="false" AllowSorting="false" DataSourceID="Vendor_Details1" CurrentPageIndex="0"
            OnUpdateCommand="GrdCategoryDetails_UpdateCommand" PageSize="10" AllowPaging="true"
            Width="98%" AllowAddingRecords="false">
            <ClientSideEvents OnClientSelect="Select_Vendor" OnBeforeClientUpdate="validateUpdateAmount"
                OnClientUpdate="onCommand" ExposeSender="true" />
            <Columns>
                <obout:Column DataField="ORG_ID" Visible="false" HeaderText="Org ID" ReadOnly="true"
                    Width="0%">
                </obout:Column>
                <obout:Column DataField="VENDOR_ID" Visible="false" HeaderText="Vendor ID" ReadOnly="true"
                    Width="0%">
                </obout:Column>
                <obout:Column DataField="VENDOR_NAME" Visible="true" HeaderText="Vendor Name" ReadOnly="true"
                    Width="33%">
                </obout:Column>
                <obout:Column DataField="OUTSTANDING_AMT" Visible="true" HeaderText="Outstanding Amt"
                    HeaderAlign="right" Align="right" ReadOnly="true" Width="33%">
                </obout:Column>
                <obout:Column DataField="OUTSTANDING_REQ_AMT" Visible="true" HeaderText="Outstanding Req Amt"
                    HeaderAlign="right" Align="right" Width="33%">
                    <TemplateSettings EditTemplateId="tmpOtAmount" />
                </obout:Column>
                <obout:Column ID="Column1" AllowEdit="true" HeaderText="Edit" Width="100" runat="server">
                </obout:Column>
            </Columns>
            <Templates>
                <obout:GridTemplate runat="server" ID="tmpOtAmount" ControlID="txtOUTSTANDING_REQ_AMT"
                    ControlPropertyName="value">
                    <Template>
                        <obout:OboutTextBox ID="txtOUTSTANDING_REQ_AMT" runat="server" class="ob_gEC" Text="<%# Container.Value %>" />
                        <%--        <input type="text" id="txtOUTSTANDING_REQ_AMT" class="ob_gEC" value="<%# Container.Value %>" />--%>
                    </Template>
                </obout:GridTemplate>
            </Templates>
        </obout:DetailGrid>
    </DetailGrids>
</obout:DetailGrid>

and here is my code for find the current page index of Details Grid

Session["CurrentPageIndex"] = GrdvendorDetailsGrid.CurrentPageIndex.ToString();
INDIA IT TECH
  • 1,902
  • 4
  • 12
  • 25
ash060
  • 137
  • 2
  • 4
  • 14
  • what exactly is the issue here, please can you explain bit more. – sumngh Apr 19 '16 at 10:33
  • issue is that we have a nested Grid(child Grid) if am click on the Page number 2 of child Grid then we want put the Page number in session. – ash060 Apr 19 '16 at 10:36
  • and what the error exactly you are getting.... – sumngh Apr 19 '16 at 10:39
  • is there any class with the name 'GrdvendorDetailsGrid' in your code? – sumngh Apr 19 '16 at 10:40
  • GrdvendorDetailsGrid is the ID of Details Grid if you see my Grid Code then you will get it and there is no error but we are getting page index number is 0 – ash060 Apr 19 '16 at 10:42
  • yes I have checked that 1, I was making sure that you haven't created any class with the same name. Please try the code below if that helps to you, I have attached the source link for further information. – sumngh Apr 19 '16 at 10:55

3 Answers3

0

For getting current page index you can try this

        if(HttpContext.Current.Request["myGVPageId"] != null])
        {
            myGridview.PageIndex =  Convert.ToInt32(HttpContext.Current.Request["myGVPageId"]);
        }

more help on Maintaining GridView current page index after navigating away from Gridview page

Community
  • 1
  • 1
sumngh
  • 566
  • 2
  • 10
  • can you tell me that what is Grid_Change Please? – ash060 Apr 19 '16 at 12:14
  • there will be an event for the Grid which calls on any changes on the grid like when we change the page – sumngh Apr 19 '16 at 12:21
  • so where we can mention it i mean on which event? – ash060 Apr 19 '16 at 12:27
  • can you confirm one thing for your code, have you tried by clicking again on any other page and check that it is giving 0 value always. As CurrentPageIndex is a zero-value based property, so may be possibilities that it is picking 0 value for the first time. – sumngh Apr 19 '16 at 12:35
  • i think this grid is different from other web grids and they have only limited events for the grid. There are no events for any changes on the grid. – sumngh Apr 19 '16 at 12:37
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/109553/discussion-between-a-t-and-sumer-singh). – ash060 Apr 19 '16 at 12:55
0

You can use PageIndexChanging event of the grid to capture page index and store in session.

protected void GridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
    int PageIndex = e.NewPageIndex;   
}
Telan Niranga
  • 437
  • 3
  • 10
0

If you're doing the paging on front-end, just do it this way

<asp:TemplateField HeaderText="#">
    <ItemTemplate>
        <%# (Container.DataItemIndex + 1) + (gvReport.PageSize * gvReport.PageIndex) %>
    </ItemTemplate>
</asp:TemplateField>

Load the PageSize and PageIndex of your GridView

TPG
  • 2,811
  • 1
  • 31
  • 52