How to make textbox in datagrid appears alternating back-color?

Discussion in 'ASP .Net' started by rockdale, Jun 2, 2006.

  1. rockdale

    rockdale 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
    rockdale, Jun 2, 2006
    #1
    1. Advertising

  2. rockdale

    rockdale Guest

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

    rockdale 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
    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. Matt Adams
    Replies:
    0
    Views:
    887
    Matt Adams
    Aug 26, 2003
  2. Replies:
    2
    Views:
    3,343
  3. cho.cabot
    Replies:
    3
    Views:
    1,183
    Jonathan N. Little
    Nov 13, 2006
  4. fig000
    Replies:
    0
    Views:
    4,547
    fig000
    Sep 6, 2004
  5. Kamaljeet Saini
    Replies:
    0
    Views:
    412
    Kamaljeet Saini
    Feb 13, 2009
Loading...

Share This Page