gridview: column width, wrap simplification?

  • Thread starter Thread starter Beemer Biker
  • Start date Start date
B

Beemer Biker

I finally got a bound column in a gridview to be the size I wanted and for
the text to wrap correctly. This took a while with about 1/2 googling and
the other 1/2 guesswork. I was wondering if I did this correct or if there
was a better way (other than makeing a template).

I created "mytable { table-layout:fixed; }" css class and put it on the
gridview at its CssClass.

I set the ItemStyle width to 320px and Wrap to True for the column I wanted
to be 320px.

In the callback gridview1_RowCreated I set the cell width to 300px for that
column.
This gave an extra 20 pixels in the cell box after the text "wrapped".

Unless all of the above happened, I could not get it to resize at all.

It seems to me that all of this could have been avoided if I could bind the
text into the cell using some type of format string. ie: Where the column
has HtmlEncode, make it False; and for the DataFormatString, put in
something like "{0,120:}" where it would write out at most 120 characters
before wrapping. There probably isnt a format specifier like that.

I sure did see a lot of people asking how to vary the size of a gridview
column with many responding "that didnt work" when told to simply use
"ItemStyle-Width=320px" They were sure right.

sorry for the rant.

Anyway, it seem to be a real pain to set column width to arbitrary sizes
using VS2008 right out of the box.
 
Back
Top