Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Set style or width at column level of datagrid

Reply
Thread Tools

Set style or width at column level of datagrid

 
 
Matt
Guest
Posts: n/a
 
      06-30-2003
I have a datagrid that is using some custom styles very nicely by
using the following code:

<aspataGrid 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?
 
Reply With Quote
 
 
 
 
Tim
Guest
Posts: n/a
 
      07-01-2003
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

"Matt" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> I have a datagrid that is using some custom styles very nicely by
> using the following code:
>
> <aspataGrid 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?



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to set table column width except the last column? Cal Java 1 01-08-2007 06:55 AM
setting Column width of Template Column in Datagrid.. Charleees ASP .Net 2 06-20-2006 12:52 PM
c is a low-level language or neither low level nor high level language pabbu C Programming 8 11-07-2005 03:05 PM
Textbox width scaling to width of data not width of page? AndrewF ASP .Net 1 10-10-2005 04:38 PM
DG Column Width vs Table Column Width Carl Howarth ASP .Net Datagrid Control 1 10-24-2004 08:48 AM



Advertisments