0

[利用 Visual Studio、ASP.NET、C# 和 IE8]

我在更新面板中有一个非常标准的网格视图。MasterPage 上的脚本管理器。UpdatePanel 设置为 UpdateMode:始终。

但是,现在我的添加到 SQL 数据库和数据绑定功能非常流畅,您只需看到添加到 gridview 的新行。当我[删除]时,该行被快速删除,gridview下方的输入提交表自动向上移动以填充现在缺少的行。

在所有这些功能中,视图基本上保持在同一个位置,并确保操作顺畅。

但是,当在 GridView 上使用 Gridview>Edit Columns>CommandField>Edit、Update、Cancel 按钮时,当您单击 [Edit] 时,页面似乎向上移动了大约 10 行。然后,当您点击 [Cancel] 时,它会将您降低 5 行。与 [更新] 相同。它使编辑每个提交的任务只是一次又一次地找到你的位置。

    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="asdfasdf" Width="1200px" DataKeyNames="pk_id" CellPadding="4" 
    ForeColor="#333333" GridLines="None">
    <RowStyle BackColor="#EFF3FB" />
<Columns>
    <asp:CommandField ButtonType="Button" ShowEditButton="True">
        <HeaderStyle Width="5%" />
    </asp:CommandField>
    <asp:BoundField DataField="question" HeaderText="Question" 
        SortExpression="question" >
        <HeaderStyle Width="35%" />
    </asp:BoundField>
    <asp:BoundField DataField="answer_A" HeaderText="Choice A" 
        SortExpression="answer_A" >
        <HeaderStyle Width="10%" />
    </asp:BoundField>
    <asp:BoundField DataField="answer_B" HeaderText="Choice B" 
        SortExpression="answer_B" >
        <HeaderStyle Width="10%" />
    </asp:BoundField>
    <asp:BoundField DataField="answer_C" HeaderText="Choice C" 
        SortExpression="answer_C" >
        <HeaderStyle Width="10%" />
    </asp:BoundField>
    <asp:BoundField DataField="answer_D" HeaderText="Choice D" 
        SortExpression="answer_D" >
        <HeaderStyle Width="10%" />
    </asp:BoundField>
    <asp:BoundField DataField="answer_E" HeaderText="Choice E" 
        SortExpression="answer_E" >
        <HeaderStyle Width="10%" />
    </asp:BoundField>
    <asp:BoundField DataField="correct_answer" HeaderText="Answer" 
        SortExpression="correct_answer" >
        <HeaderStyle Width="5%" />
    </asp:BoundField>
    <asp:CommandField ButtonType="Button" ShowDeleteButton="True">
        <HeaderStyle Width="5%" />
    </asp:CommandField>
</Columns>
    <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
    <PagerTemplate>
        asd
    </PagerTemplate>
    <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
    <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
    <EditRowStyle BackColor="#2461BF" />
    <AlternatingRowStyle BackColor="White" />

4

0 回答 0