Add Attribute to <TD>

J

J Holsinger

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
 
J

J Holsinger

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>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top