How to turn wrapping off for datagrid columns

  • Thread starter Thread starter Scott
  • Start date Start date
S

Scott

I having a problem where I need to turn off the wrapping feature for
all columns in my datagrid. Example code would be:

<asp:DataGrid id="ResultGrid" runat="server"
AutoGenerateColumns="true">
<ItemStyle Wrap="false"></ItemStyle>
<Columns>
</Columns>
</asp:DataGrid>

I understand the above code does not turn the wrapping feature off on
the <td> level, but only the <tr> level which is not what I want. I
also understand that this is a Microsoft bug and in order to fix it, I
have to add the asp:BoundColumn along with the ItemStyle
(wrap="false") for each column. While this is ok if you know what the
columns are going to be, but in my case I'm dynamically building
columns based on what table in the database the user has chosen. So I
don't know what the columns will be or how many.

Has anybody come across this and if you have, can you give me some
hints or examples which would allow me to turn wrapping off for all
columns.

Thanks.
 
You know, I posted this question too quick without really thinking
Andrew and I didn't even consider CSS. I've been coding ASP for years
and I just need to shift my "set of rules" over to ASP.Net. Since my
problem was trying to turn the nowraping off on the <td> tags, I just
added the following code:

<STYLE>
td
{
FONT-SIZE: 9pt;
FONT-FAMILY: Verdana;
WHITE-SPACE: nowrap;
PADDING: 2;
}
</STYLE>

and it worked.

Thanks Andrew!
 
Back
Top