Add Attribute to <TD>

Discussion in 'ASP .Net Datagrid Control' started by J Holsinger, Jan 4, 2005.

  1. J Holsinger

    J Holsinger Guest

    Does anybody know how to add the html 'nowrap' attribute to a particular
    column in a datagrid?

    This doesn't work, because I suspect the attributes are readonly at this
    point:
    Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As
    System.Web.UI.WebControls.DataGridItemEventArgs) Handles
    DataGrid1.ItemDataBound
    Dim Cell As TableCell = e.Item.Cells(3)
    Cell.Wrap = True

    'Cell.Attributes("nowrap") = "nowrap"
    'Dim myHttpResponse As HttpResponse = Response
    'Dim myHtmlTextWriter As New HtmlTextWriter(myHttpResponse.Output)
    'Cell.Attributes.AddAttributes(myHtmlTextWriter)
    End Sub

    --

    thx
    -jsh
    J Holsinger, Jan 4, 2005
    #1
    1. Advertising

  2. J Holsinger

    J Holsinger Guest

    Figured it out. What my intent was to turn on word wrapping, which was
    confused in my original post.
    I used the following and I got what I wanted.

    <head>
    <style type="text/css">
    <!--
    .col_break{
    vertical-align:top;
    word-wrap:break-word;
    width:30%;}
    //-->
    </style>
    </head>
    <body ms_positioning="GridLayout">
    <asp:datagrid id="DataGrid1" runat="server"
    allowsorting="true"
    onsortcommand="DataGrid1_Sort"
    autogeneratecolumns="False"
    width="100%">
    <columns>
    <asp:boundcolumn
    headertext="Description"
    datafield="description"
    sortexpression="description"
    itemstyle-cssclass="col_description">
    </asp:boundcolumn>
    </columns>
    </asp:datagrid>
    </body>
    </html>

    --

    thx
    -jsh
    J Holsinger, Jan 4, 2005
    #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. Bostonasian
    Replies:
    1
    Views:
    806
    Joris Gillis
    Sep 18, 2005
  2. Replies:
    2
    Views:
    1,064
    Henry S. Thompson
    Mar 6, 2006
  3. Donnal Walter

    class attribute to instance attribute

    Donnal Walter, Jun 30, 2005, in forum: Python
    Replies:
    4
    Views:
    447
    Greg Ewing
    Jul 6, 2005
  4. Russell Warren
    Replies:
    5
    Views:
    455
    Russell Warren
    Jan 17, 2006
  5. anonymous
    Replies:
    1
    Views:
    5,920
Loading...

Share This Page