在asp.net的GridView的设置列宽 [英] set column width of a gridview in asp.net
问题描述
我拖放一个GridView控件从工具箱.aspx的PAGE电泳设计code看起来像这样
I dragged and dropped a GridView from toolbox to Aspx page.the design code looks like this
<asp:GridView ID="gridview1" runat="server" style="text-align:center;width: 1327px;"
CellPadding="4" ForeColor="#333333" GridLines="None" AllowPaging="True"
EnableSortingAndPagingCallbacks="True" PageSize="50" AutoGenerateEditButton="True">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center"
Height="12px" VerticalAlign="Bottom" Width="12px" Wrap="False" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
我的名字地址在database.The表中的列绑定到使用此网格视图以下VB.NET code
I have a column by name Address in database.The table is bound to this grid view using following VB.NET code
Dim ds as Data.DataSet
Dim da As New OleDbDataAdapter("select col1,col2,col3,col4,col5,col6,col7,col8,col9,col10,Address from table, con)
da.Fill(ds)
gridviewrealestate.DataSource = ds
gridviewrealestate.DataBind()
现在,当显示在GridView中,列非常接近对方由于地址Column.I大型信息present要在地址栏设置为特定的宽度。
请帮助我如何做到这一点。
Now,When the gridview is displayed,the columns are very close to each other due to large information present in Address Column.I want to set the Address Column to a particular width. Please help me how to do this.
推荐答案
您不能(容易),如果在GridView自动生成的栏更改网格视图的列的大小。你将不得不自己创建的列,但是这会让你控制列它们的布局,以及许多其他方面。
在创建GridView的自定义列
You cannot (easily) change the size of a grid view's columns if the GridView is automatically generating the columns for you. You will have to create the columns yourself but this will let you control the layout of the columns as well as many other aspects of them as well. Creating custom columns in gridview
这篇关于在asp.net的GridView的设置列宽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!