asp.net c#obout详细信息Grid获取当前页面索引

时间:2016-04-19 10:13:16

标签: c# asp.net obout

我正在使用obout Grid并且正在创建详细信息网格我想找出当前页面索引的详细信息网格(子网格)  我的网格在

之下
<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>

这是我的代码,用于查找详细信息网格的当前页面索引

Session["CurrentPageIndex"] = GrdvendorDetailsGrid.CurrentPageIndex.ToString();

3 个答案:

答案 0 :(得分:0)

要获取当前页面索引,您可以尝试此

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

Maintaining GridView current page index after navigating away from Gridview page

的更多帮助

答案 1 :(得分:0)

您可以使用网格的PageIndexChanging事件来捕获页面索引并存储在会话中。

protected void GridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
    int PageIndex = e.NewPageIndex;   
}

答案 2 :(得分:0)

如果您正在前端进行分页,请按照这种方式进行

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

加载GridView的PageSize和PageIndex