在div内维护gridview的滚动位置

时间:2014-03-19 10:44:03

标签: c# asp.net gridview

我有一个包含脚本管理器的母版页。在子页面中,我有一个带有复选框和一些文本框的可滚动网格视图

    <div id="grdScr" style ="width:130%;  overflow:auto" align="center" >
        <asp:GridView ID="dgvBill" runat="server" AutoGenerateColumns="False" 
            BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" 
            CellPadding="4" ForeColor="Black" GridLines="Horizontal" PageSize="100" 
            Width="150%">
            <Columns>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:CheckBox ID="chkSelect" runat="server" AutoPostBack="True" 
                            oncheckedchanged="chkSelect_CheckedChanged" />
                        <asp:Label ID="lblVendCd" runat="server" Text='<%# Eval("vend_cd") %>' 
                            Visible="false"></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Bill date">
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Eval("bill_dt") %>'></asp:Label>
                        <asp:Label ID="lbltrid" runat="server" Text='<%# Eval("tr_id") %>' 
                            Visible="False"></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Bill no">
                    <ItemTemplate>
                        <asp:Label ID="lblBillNO" runat="server" Text='<%# Eval("bill_no") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Vendor">
                    <ItemTemplate>
                        <asp:Label ID="Label3" runat="server" Text='<%# Eval("vend_nm") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Supplier">
                    <ItemTemplate>
                        <asp:Label ID="Label4" runat="server" Text='<%# Eval("supplier") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Driver">
                    <ItemTemplate>
                        <asp:Label ID="Label5" runat="server" Text='<%# Eval("driver") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Vechicle Type">
                    <ItemTemplate>
                        <asp:Label ID="Label6" runat="server" Text='<%# Eval("comm_nm") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Vehicle No">
                    <ItemTemplate>
                        <asp:Label ID="Label7" runat="server" Text='<%# Eval("veh_no") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Payable Amount">
                    <ItemTemplate>
                        <asp:Label ID="Label8" runat="server" Text='<%# Eval("payable") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Cash">
                    <ItemTemplate>
                        <asp:TextBox ID="txtCashGrid" runat="server" AutoPostBack="True" 
                            Enabled="False" ontextchanged="txtCashGrid_TextChanged" 
                            style="text-align: right" Width="75px" onkeypress="return isNumberKey(event)">0.00</asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Cheque">
                    <ItemTemplate>
                        <asp:TextBox ID="txtChequeGrid" runat="server" AutoPostBack="True" 
                            Enabled="False" ontextchanged="txtChequeGrid_TextChanged" 
                            style="text-align: right" Width="75px" onkeypress="return isNumberKey(event)">0.00</asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Bank">
                    <ItemTemplate>
                        <asp:TextBox ID="txtBankNameGrid" runat="server" Width="174px" 
                            AutoPostBack="True" ontextchanged="txtBankNameGrid_TextChanged"></asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Cheque No">
                    <ItemTemplate>
                        <asp:TextBox ID="txtChqNoGrid" runat="server" Width="75px" AutoPostBack="True" 
                            ontextchanged="txtChqNoGrid_TextChanged"></asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Cheque Date">
                    <ItemTemplate>
                        <asp:TextBox ID="txtChDateGrid" runat="server" AutoPostBack="True" 
                            EnableTheming="True" Width="97px" 
                            ontextchanged="txtChDateGrid_TextChanged"></asp:TextBox>
                        <cc1:TextBoxWatermarkExtender ID="txtChDateGrid_TextBoxWatermarkExtender" 
                            runat="server" Enabled="True" TargetControlID="txtChDateGrid" 
                            WatermarkText="dd-MMM-yyyy">
                        </cc1:TextBoxWatermarkExtender>
                        <cc1:CalendarExtender ID="txtChDateGrid_CalendarExtender" runat="server" 
                            Enabled="True" Format="dd-MMM-yyyy" TargetControlID="txtChDateGrid">
                        </cc1:CalendarExtender>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <FooterStyle BackColor="#CCCC99" ForeColor="Black" />
            <PagerStyle BackColor="White" ForeColor="Black" HorizontalAlign="Right" />
            <SelectedRowStyle BackColor="#CC3333" Font-Bold="True" ForeColor="White" 
                HorizontalAlign="Center" />
            <HeaderStyle BackColor="#333333" Font-Bold="True" ForeColor="White" 
                HorizontalAlign="Center" />
            <AlternatingRowStyle BackColor="#CCCCCC" HorizontalAlign="Center" />
            <RowStyle HorizontalAlign="Center" />
        </asp:GridView>
    </div>

我的gridview位于更新面板中。文本框在他们的TextChange事件中的gridview中进行了一些数学计算,并且autopostback对他们来说是真的。

每当我按Tab键将光标移动到下一个文本框时,页面都会被回发并且不保持滚动位置。我该如何解决这个问题?

0 个答案:

没有答案