gridview: column width, wrap simplification?

Discussion in 'ASP .Net' started by Beemer Biker, Jan 26, 2009.

  1. Beemer Biker

    Beemer Biker Guest

    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
    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.
    Beemer Biker, Jan 26, 2009
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. AD
  2. Replies:
  3. Carl Howarth

    DG Column Width vs Table Column Width

    Carl Howarth, Oct 22, 2004, in forum: ASP .Net Datagrid Control
    Eliyahu Goldin
    Oct 24, 2004
  4. Dan English

    GridView columns don't respect width or wrap properties!

    Dan English, Jul 6, 2006, in forum: ASP .Net Web Controls
    Akash Deep
    Jul 14, 2006
  5. Replies:

Share This Page