limit colunm width in gridview

Discussion in 'ASP .Net' started by graphicsxp, May 23, 2006.

  1. graphicsxp

    graphicsxp Guest

    Hi,
    I've come across a few solutions on the forum for this problem but it
    still don't work :(

    I have a column that can contains very long text value. I was hoping
    the value would be truncated to the size of the column's width. So I
    did the following :

    Protected Sub grdCuttings_RowCreated(ByVal sender As Object, ByVal e
    As System.Web.UI.WebControls.GridViewRowEventArgs) Handles
    grdCuttings.RowCreated
    Dim iWidth As Integer = 100
    If e.Row.RowType = DataControlRowType.DataRow Then
    For r As Integer = 0 To Me.grdCuttings.Columns.Count - 1
    Me.grdCuttings.Columns(r).ItemStyle.Width = iWidth
    Me.grdCuttings.Columns(r).ItemStyle.Wrap = False
    Next
    End If
    End Sub
    It changes the width but the text is wrapped instead of being
    truncated..

    Can you help ?
    graphicsxp, May 23, 2006
    #1
    1. Advertising

  2. Um... you can't really... actually that's not true.

    You can specify a number of characters to place in the field, but your
    users may have different font settings to you, and their text will wrap
    anyway.

    You can try setting the no-wrap CSS attribute on your cells and
    specifying overflow: hidden; but I don't know how well that will work.
    It's not the sort of thing you tend to do very often on a webpage.
    Flinky Wisty Pomm, May 23, 2006
    #2
    1. Advertising

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. AndrewF
    Replies:
    1
    Views:
    758
    Bruce Barker
    Oct 10, 2005
  2. Replies:
    0
    Views:
    457
  3. Replies:
    1
    Views:
    719
    Eliyahu Goldin
    Jan 9, 2007
  4. Replies:
    0
    Views:
    926
  5. bthumber
    Replies:
    0
    Views:
    352
    bthumber
    Jun 25, 2010
Loading...

Share This Page