Set style or width at column level of datagrid

M

Matt

I have a datagrid that is using some custom styles very nicely by
using the following code:

<asp:DataGrid id="DataGrid1" runat="server" Width="828px"
ShowFooter="True" >
<SelectedItemStyle CssClass="DataGrid_SelectedItemStyle"></SelectedItemStyle>
<ItemStyle CssClass="DataGrid_ItemStyle"></ItemStyle>
<HeaderStyle CssClass="DataGrid_HeaderStyle"></HeaderStyle>
<FooterStyle CssClass="DataGrid_FooterStyle"></FooterStyle>
<Columns> ...

The problem is that I want to set the width of SOME columns with a
style sheet setting. The only way I found to control the width was to
hard code it in the column definition. Here's a template column that
works:

<asp:TemplateColumn HeaderText="FTE">
<HeaderStyle Width="10px"></HeaderStyle>
<ItemStyle Width="10px"></ItemStyle>
<FooterStyle Width="10px"></FooterStyle>
<ItemTemplate>
<asp:Label id="lblFTE" Width="40px" runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "fte") %>'>
</asp:Label></ItemTemplate>
<FooterTemplate>
<asp:textbox id="txtFTE_Add" Width="40px" Text=""
Runat="server"></asp:textbox>
</FooterTemplate>
<EditItemTemplate>
<asp:TextBox id="txtFTE_Edit" Width="40px" runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "fte") %>'>
</asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>

I tried using the cssclass="abc" parm inside each template declaration
but that had zero effect.

I want someway to set the individual column width using Styles.css so
I can change it quickly for several columns at once. Any ideas?
 
T

Tim

Good Luck, I've tried exactly what your trying, with no effect. I got
ASP.net Web Matrix to see if it was in there. But I guess there isn't
anything you can do? My resort was placing blank images that were 1px high
and the width I wanted the columns to be, thus making it wider.

Lemme know if that idea works for you.

Tim
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top