ASP.NET设置GridView列的最大宽度大小 [英] ASP.NET Set GridView Column max width size
问题描述
我在VS2005上使用ASP.NET C#.
I am using ASP.NET C# on VS2005.
我有一个GridView表,其中的列名为Description
,并且由于输入始终很长,因此描述在水平方向上很长.
I have a GridView table with a column named Description
, and since the input is always very long, the description is very long horizontally.
我希望GridView的所有列都具有最大宽度.
I would want the GridView to have a max width size for all columns.
我尝试了很多方法,但是没有一个起作用.
I have tried many ways but none of them worked.
ItemStyle-Width="50px"
,
HeaderStyle-BorderWidth="50px"
,
HeaderStyle-Width="50px"
,
RowStyle-Width="50px"
,
Width="50px"
下面是我的GridView的代码段:
Below is a code snippet of my GridView:
<asp:GridView ID="GridView1" AutoGenerateEditButton="True" ondatabound="gv_DataBound" runat="server" DataSourceID="SqlDataSource1">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="UserSelector" OnCheckedChanged="UserSelector_CheckedChanged" ondatabound="gv_DataBound" runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
有人知道如何根据我的情况调整GridView列的大小吗?
Anyone know how to adjust the size of GridView columns based on my situation?
推荐答案
我更改了我的代码,这就是你在想的吗?
I changed my code is this what you where thinking bout?
<RowStyle Width="150px"/>
删除所有藏匿处
<asp:TemplateField><ItemTemplate> </ItemTemplate></asp:TemplateField>
只需使用简单
<columns> </columns>
在这里,我认为您的代码看起来像AutoGenerateColumns ="True"或错误的无关紧要的东西
Here i how i think you code will look like AutoGenerateColumns="True" or false dont seeme to matter
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="true" DataSourceID="SqlDataSource1">
<Columns>
<asp:CheckBox ID="UserSelector" OnCheckedChanged="UserSelector_CheckedChanged" ondatabound="gv_DataBound" runat="server" />
</Columns>
<RowStyle Width="150px"/>
</asp:GridView>
这篇关于ASP.NET设置GridView列的最大宽度大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!