ASP.NET 2.0中的Gridview列宽

8 asp.net gridview

如何在ASP.NET 2.0中的gridview控件中控制列宽?

ach*_*a99 8

您可以使用HeaderStyle-Width,ItemStyle-Width或FooterStyle-Width属性.这些可以应用于所有列或每列.

    <asp:GridView ID="GridView1" runat="server">
        <HeaderStyle Width="10%" />
        <RowStyle Width="10%" />
        <FooterStyle Width="10%" />
        <Columns>
            <asp:BoundField HeaderText="Name" DataField="LastName" 
                HeaderStyle-Width="10%" ItemStyle-Width="10%"
                FooterStyle-Width="10%" />
        </Columns>
    </asp:GridView>
Run Code Online (Sandbox Code Playgroud)


DCN*_*YAM 3

我使用列的标题样式来完成此操作:

<asp:BoundField HeaderText="Name" DataField="LastName">
   <HeaderStyle Width="20em" />
</asp:BoundField>
Run Code Online (Sandbox Code Playgroud)