I've got an asp.net GridView and within it a few BoundFields.
<asp:BoundField ReadOnly="True" HeaderText="ID" DataField="ID" SortExpression="ID"></asp:BoundField>
<asp:BoundField ReadOnly="True" HeaderText="Description" DataField="description" ItemStyle-Wrap="true" ItemStyle-Width="300px" SortExpression="ID"></asp:BoundField>
The text within the description field can be of any length, so for right now I've set the column to just be 300px wide, and wrap the text when necessary.
But what I'd like to implement is where the width is automatically set, like in a normal BoundField up until it reaches 300px in width. After that I'd like it to wrap around.
I thought of trying to implement this during the DataBound event, where I can look at the length of every string that's being added to the table. If it reaches a certain length, I'd add the ItemStyle-Width property to the BoundField.
The problem is that BoundFields aren't given ID's so I can't do the normal way of changing properties in the code behind. I figure it's possible to get at these properties by going through the GridView's ID, but I'm not sure where to add the property.