How to set bach-color of textbox in datagrid same as AlternatingItemStyle

Discussion in 'ASP .Net Datagrid Control' started by rockdale.green@gmail.com, Jun 2, 2006.

  1. Guest

    Hi, All
    I have an datagrid with alternating color, I also want the back-color
    of my textbox in ItemTemplate also appears alternating, how could I do
    that?

    <asp:datagrid id="dgridEmpHours" width="100%" runat="server"
    DataKeyField="employee_key" AutoGenerateColumns="False"
    BorderWidth="0" CellPadding="2" cellSpacing="1"
    GridLines="None" ShowFooter="True">
    <AlternatingItemStyle CssClass="AltBoldtext" />
    <ItemStyle CssClass="Boldtext" />
    <Columns>
    <asp:TemplateColumn SortExpression="employee_Key" HeaderText="employee
    Key">
    <ItemTemplate>
    <asp:Label id="lblEmployeeKey" Visible=False runat="server"
    Text='<%# DataBinder.Eval(Container, "DataItem.employee_key") %>'>
    </asp:Label>
    </ItemTemplate>
    </asp:TemplateColumn>
    <asp:TemplateColumn SortExpression="hours" HeaderText="Hours" >
    <ItemTemplate>
    <asp:TextBox id=txtHours runat="server" Text='<%#
    DataBinder.Eval(Container, "DataItem.Hours") %>'>
    </asp:TextBox>
    </ItemTemplate>
    </asp:TemplateColumn>

    Thanks a lot
    -Rockdale
     
    , Jun 2, 2006
    #1
    1. Advertising

  2. Guest

    Nevermind, I can change the back-color in the ItemDataBound event

    wrote:
    > Hi, All
    > I have an datagrid with alternating color, I also want the back-color
    > of my textbox in ItemTemplate also appears alternating, how could I do
    > that?
    >
    > <asp:datagrid id="dgridEmpHours" width="100%" runat="server"
    > DataKeyField="employee_key" AutoGenerateColumns="False"
    > BorderWidth="0" CellPadding="2" cellSpacing="1"
    > GridLines="None" ShowFooter="True">
    > <AlternatingItemStyle CssClass="AltBoldtext" />
    > <ItemStyle CssClass="Boldtext" />
    > <Columns>
    > <asp:TemplateColumn SortExpression="employee_Key" HeaderText="employee
    > Key">
    > <ItemTemplate>
    > <asp:Label id="lblEmployeeKey" Visible=False runat="server"
    > Text='<%# DataBinder.Eval(Container, "DataItem.employee_key") %>'>
    > </asp:Label>
    > </ItemTemplate>
    > </asp:TemplateColumn>
    > <asp:TemplateColumn SortExpression="hours" HeaderText="Hours" >
    > <ItemTemplate>
    > <asp:TextBox id=txtHours runat="server" Text='<%#
    > DataBinder.Eval(Container, "DataItem.Hours") %>'>
    > </asp:TextBox>
    > </ItemTemplate>
    > </asp:TemplateColumn>
    >
    > Thanks a lot
    > -Rockdale
     
    , Jun 2, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wayne  Wengert

    Set TextBox Background Color

    Wayne Wengert, Feb 12, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    22,574
    Wayne Wengert
    Feb 12, 2005
  2. =?Utf-8?B?T2Zlcg==?=

    set cell color while rendered in a datagrid

    =?Utf-8?B?T2Zlcg==?=, Apr 1, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    2,940
    Elton Wang
    Apr 2, 2005
  3. rockdale
    Replies:
    1
    Views:
    2,427
    rockdale
    Jun 2, 2006
  4. psb
    Replies:
    0
    Views:
    170
  5. Kamaljeet Saini
    Replies:
    0
    Views:
    434
    Kamaljeet Saini
    Feb 13, 2009
Loading...

Share This Page