你如何在ASP.NET 2.0中控制GridView控件中列的宽度?
ASP.NET 2.0中的GridView列宽
原标题:
问题回答
您可以使用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>
我使用列的标题样式来做这件事:
<asp:BoundField HeaderText="Name" DataField="LastName">
<HeaderStyle Width="20em" />
</asp:BoundField>
这是实现它的 C# 代码:
columnName.ItemStyle.Width = Unit.Percentage(someDouble);
Gridview.Columns[1].ItemStyle.Width = 100;
这将设置像素宽度。
相关问题
热门标签
- winforms
- combobox
- fogbugz
- java
- date
- internationalization
- asp.net
- iis
- url-rewriting
- urlrewriter
- c#
- enums
- ocaml
- haxe
- algorithm
- string
- viewstate
- .net
- c++
- c
- symbol-table
- mysql
- database
- postgresql
- licensing
- migration
- vb.net
- vb6
- declaration
- vb6-migration
- python
- psycopg2
- backup
- vmware
- virtualization
- gnu-screen
- authentication
- desktop
- excel
- xll
- cultureinfo
- regioninfo
- oracle
- client
- session
- download
- html
- virtual
- constructor
- scenarios
- perl
- full-text-search
- javascript
- ajax
- testing
- oop
- inheritance
- vim
- encapsulation
- information-hiding