Create maximum width for GridView column and Wrap Text

I cannot determine how to determine the width of a particular gridview column. I get this result:

enter image description here

As you can see, I get a substantial overflow. I would like to determine the maximum width and wrap the test for this 5th column.

I tried to do this programmatically:

GridView1.Columns[4].ItemStyle.Width = 300; GridView1.DataBind(); 

And also in asp.net:

 <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" ItemStyle-Width="300px" /> 

or

 <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" HeaderStyle-Width="300px"> 

None of these attempts have any effect.

+7
c # gridview
source share
2 answers

Use the following css class for the grid:

 .gridView { table-layout:fixed; } 

and in the column use this css class:

 .col { word-wrap:break-word; } 
+12
source share

The text in the upper last column has no spaces. This means that the last column will not be wrapped so that the table is stretched. This is like displaying a really large image that is too large for a container or page.

+1
source share

All Articles