在浏览器窗口的顶部显示内容

时间:2014-04-01 04:50:53

标签: asp.net gridview

当我添加,删除,更新操作时,我需要始终在表单的标题位置显示此网格。任何身体请帮助我。提前谢谢。

      <asp:GridView ID="Grd_View" ShowFooter="True" runat="server" OnRowEditing="Grd_View_RowEditing" AutoGenerateColumns="False"
    DataKeyNames="CustomerCode" CellPadding="4" OnRowCommand="Grd_View_RowCommand" GridLines="None"
    AllowPaging="True" AllowSorting="True" CssClass="style2" ForeColor="#333333" Width="569px" OnRowDataBound="Grd_View_RowDataBound" OnRowDeleting="Grd_View_RowDeleting">
    <FooterStyle BackColor="#555555" ForeColor="White" Font-Bold="True" />
    <Columns>
        <asp:BoundField DataField="CustomerCode" HeaderText="CustomerCode" InsertVisible="False"
            ReadOnly="True" SortExpression="CustomerCode" />

        <asp:BoundField DataField="CustomerName" HeaderText="CustomerName" SortExpression="CustomerName" />

        <asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" />
        <asp:BoundField DataField="TellNo" HeaderText="TellNo" SortExpression="TellNo" />
        <asp:BoundField DataField="FaxNo" HeaderText="FaxNo" SortExpression="FaxNo" />
        <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
        <asp:TemplateField>
            <ItemTemplate>
                <asp:LinkButton ID="btnEdit" runat="server" CommandArgument='<%#Eval("CustomerCode")%>' CommandName="Edit" Text="Edit">
                </asp:LinkButton>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField>
            <ItemTemplate>
                <asp:LinkButton ID="btnDelete" runat="server" CommandArgument='<%#Eval("CustomerCode")%>' CommandName="Delete" Text="Delete">
                </asp:LinkButton>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField>
            <FooterTemplate>
                <asp:LinkButton ID="btnNew" runat="server" CommandArgument='<%#Eval("CustomerCode")%>' CommandName="New" Text="New">
                </asp:LinkButton>
            </FooterTemplate>
        </asp:TemplateField>

    </Columns>

    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
    <PagerStyle BackColor="#777777" ForeColor="White" HorizontalAlign="Center" />
    <HeaderStyle BackColor="#555555" Font-Bold="True" ForeColor="White" />
    <EditRowStyle BackColor="#999999" />
    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />

</asp:GridView>

2 个答案:

答案 0 :(得分:0)

您必须在Fixed Div中为固定标题包装网格视图 例如:

<div style ="height:200px; width:617px; overflow:auto;">
<asp:GridView ID="GridView1" runat="server"
    AutoGenerateColumns = "false" Font-Names = "Arial" ShowHeader = "false"
    Font-Size = "11pt" AlternatingRowStyle-BackColor = "#C2D69B" >
   <Columns>
    <asp:BoundField ItemStyle-Width = "150px" DataField = "CustomerID" />
    <asp:BoundField ItemStyle-Width = "150px" DataField = "City" />
    <asp:BoundField ItemStyle-Width = "150px" DataField = "Country" />
    <asp:BoundField ItemStyle-Width = "150px" DataField = "PostalCode" />
   </Columns>
</asp:GridView>
</div>

答案 1 :(得分:0)

将您的网格视图放在div标签内,其中顶部位置样式如下所述:

<div style="top: 0%; left: 45%; position: absolute; z-index: 999">
    <asp:GridView ID="Grd_View" ShowFooter="True" runat="server" OnRowEditing="Grd_View_RowEditing" AutoGenerateColumns="False"
        DataKeyNames="CustomerCode" CellPadding="4" OnRowCommand="Grd_View_RowCommand" GridLines="None"
        AllowPaging="True" AllowSorting="True" CssClass="style2" ForeColor="#333333" Width="569px" OnRowDataBound="Grd_View_RowDataBound" OnRowDeleting="Grd_View_RowDeleting">
        ...
        ...
        ...
    </asp:GridView>
</div>