In a handler for the ItemDataBount datagrid event, look into each cell in e.Item.Cells for a textbox control. Then explicitly define the style for it. You might be able to get away with width=100% and have the textbox fill the cell width. Seeing as the text in other rows will probably govern the overall column width, this mostly works. Here's some code:
Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemDataBound
Dim txtTextBox As TextBox
Select Case e.Item.ItemType
Case ListItemType.EditItem
For Each objCell As TableCell In e.Item.Cells
If objCell.Controls.Count > 0 Then
If TypeOf objCell.Controls(0) Is TextBox Then
txtTextBox = CType(objCell.Controls(0), TextBox)
If txtTextBox.Text.Length > 150 Then
txtTextBox.TextMode = TextBoxMode.MultiLine
txtTextBox.Rows = 4
End If
txtTextBox.Style.Item("width") = "100%"
End If
End If
Next
End Select
End Sub
-
Peter