当我单击编辑按钮时,MaintainScrollPositionOnPostback不起作用

时间:2018-09-15 11:09:15

标签: asp.net c#-4.0 visual-studio-2015 sharepoint-2013 aspxgridview

我在asp:Content页面的asp:Panel中使用asp:GridView。 GridView具有超过100行,因此我使用面板提供垂直滚动条。我在两个<%@ Page%>指令中都设置了MaintenanceScrollPositionOnPostBack =“ True”,但是当用户选择其中一行时,GridView会跳回到顶部。我在做什么错了?

谢谢

这是我的网格代码

<asp:Panel runat="server" class="tab-pane fade " ID="company_car_admin_panel_layout" role="tabpanel" aria-labelledby="company_car_admin_panel_layout_tab">
<div style="max-height:400px; overflow-y:scroll ; max-width:700px; overflow-x:scroll">
<asp:GridView ID="GridView1" runat="server" CssClass="table table-bordered" AutoGenerateColumns="false" ShowFooter="true" 
     ShowHeaderWhenEmpty="true" CellPadding="4" ForeColor="#333333" GridLines="None" Width="700px"
    DataKeyNames="ID" OnRowCommand="GridView1_RowCommand"  OnRowCancelingEdit="GridView1_RowCancelingEdit" OnRowUpdating="GridView1_RowUpdating" OnRowEditing="GridView1_RowEditing"
    OnRowDeleting="GridView1_RowDeleting">


    <Columns>

        <asp:TemplateField HeaderText="Company Car Value">

            <ItemTemplate>
                <asp:Label Text='<%# Eval("Company_Car_Value") %>' runat="server" />
            </ItemTemplate>

             <EditItemTemplate>
             <asp:TextBox ID="text_company_car_value" Text='<%# Eval("Company_Car_Value") %>' runat="server" />

             </EditItemTemplate> 
            <FooterTemplate>
            <asp:TextBox ID="text_company_car_value_footer" runat="server" />
                <asp:RequiredFieldValidator ValidationGroup="car" ID="RequiredFieldValidator1" SetFocusOnError="true" ControlToValidate="text_company_car_value_footer" runat="server"  Text="*Company value is Required" ForeColor="Red"></asp:RequiredFieldValidator>
           </FooterTemplate>
        </asp:TemplateField>

        <asp:TemplateField HeaderText="Company Car Code">

            <ItemTemplate>
                <asp:Label Text='<%# Eval("Company_Car_Code") %>' runat="server" />
            </ItemTemplate>

             <EditItemTemplate>
             <asp:TextBox ID="text_company_car_code" Text='<%# Eval("Company_Car_Code") %>' runat="server" />
            </EditItemTemplate> 

            <FooterTemplate>
            <asp:TextBox ID="text_company_car_code_footer" runat="server" />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" ValidationGroup="car" SetFocusOnError="true" runat="server" ControlToValidate="text_company_car_code_footer" Text="*Company Code is Required" ForeColor="Red"></asp:RequiredFieldValidator>
                 </FooterTemplate>

        </asp:TemplateField>

        <asp:TemplateField HeaderText="Company Car Alias">

            <ItemTemplate>
                <asp:Label Text='<%# Eval("Company_Car_Alias") %>' runat="server" />
            </ItemTemplate>

             <EditItemTemplate>
             <asp:TextBox ID="text_company_car_alias" Text='<%# Eval("Company_Car_Alias") %>' runat="server" /> 
            </EditItemTemplate> 

            <FooterTemplate>
            <asp:TextBox ID="text_company_car_alias_footer" runat="server" />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator3" SetFocusOnError="true" ValidationGroup="car" runat="server" ControlToValidate="text_company_car_alias_footer"  Text="*Company Alias is Required" ForeColor="Red"></asp:RequiredFieldValidator>
           </FooterTemplate>

        </asp:TemplateField>
         <asp:TemplateField HeaderText="Action" HeaderStyle-Width="100px">

            <ItemTemplate>
                <asp:LinkButton runat="server" CommandName="edit" ToolTip="edit" Text="<span class='table-icons'><i class='fas fa-edit'></i></span>" style="width:20px;margin-right:7px;"></asp:LinkButton>
                <asp:LinkButton runat="server" CommandName="delete" ToolTip="delete" Text="<span class='table-icons'><i class='fas fa-times'></i></span>" style="width:20px;margin-right:7px;" OnClientClick="return confirm('Are you sure you want to delete this record?');"></asp:LinkButton>
            </ItemTemplate>

            <EditItemTemplate>
                <asp:LinkButton runat="server" CommandName="Update" ToolTip="Update" Text="<span class='table-icons'><i class='far fa-save'></i></span>" style="width:20px;margin-right:7px;"></asp:LinkButton>
                <asp:LinkButton runat="server" CommandName="Cancel" ToolTip="cancel" Text="<span class='table-icons'><i class='fas fa-times'></i></span>" style="width:20px;margin-right:7px;"></asp:LinkButton>
            </EditItemTemplate>

            <FooterTemplate>
                <asp:LinkButton runat="server" ValidationGroup="car"  CausesValidation="true" CommandName="addnew" ToolTip="addnew" Text="<span class='table-icons' style='font-size:22pt;'><i class='far fa-save'></i></span>"></asp:LinkButton>
            </FooterTemplate>
        </asp:TemplateField>

    </Columns>
</asp:GridView>
<asp:PlaceHolder runat="server" ID="company_car_admin_PlaceHolder"></asp:PlaceHolder>
</div>
</asp:Panel>

这是我的母版页代码

<%@ Page Language="C#"   MaintainScrollPositionOnPostback="true" AutoEventWireup="true"  CodeBehind="WEB_SERVICE.aspx.cs" Inherits="SIRH.Layouts.SIRH.WEB_SERVICE" DynamicMasterPageFile="~masterurl/default.master" %>

0 个答案:

没有答案