创建GridView的列和自动换行最大宽度 [英] Creating max width for GridView column and Wrap Text
本文介绍了创建GridView的列和自动换行最大宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法弄清楚如何定义一个GridView的特定列的宽度。我得到这个结果:
I cant figure out how to define the width of a particular column of a gridview. I am getting this result:
正如你所看到的,我得到实质性的溢出。我想定义一个最大宽度和包裹的测试方法第5列。
As you can see, I am getting substantial overflow. I would like to define a maximum width and wrap the test for this 5th column.
我曾尝试编程这样做:
GridView1.Columns[4].ItemStyle.Width = 300;
GridView1.DataBind();
和也是在asp.net:
And also in asp.net:
<asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" ItemStyle-Width="300px" />
或
<asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" HeaderStyle-Width="300px">
这些尝试都没有遇到任何效果。
None of these attempts are having any effect.
推荐答案
使用以下CSS类网格:
Use the following css class for grid:
.gridView
{
table-layout:fixed;
}
和在列使用CSS类:
.col
{
word-wrap:break-word;
}
这篇关于创建GridView的列和自动换行最大宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文