Repeater Control: How to change change font color of <TR> or <TD>

I have a Repeater control which displays customer orders within an Html table.
I need to dynamically change the font color of each <TR> row or <TD> table data tag. The color is stored in the same row I'm displaying, so retrieving the color value is not a problem.

Am I on the right track here :

My aspx page has the repeater control as follows:

<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource_Orders" OnDataBinding="Repeater1_DataBinding" OnItemDataBound="Repeater1_ItemDataBound">

and my aspx.cs has this so far (not much really):

protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
        //    e.Item.        // how do I use this to change the color ???

Can someone provide some guidance on this matter ?

Thank you very much.
New York, New York

5/3/2006 9:25:11 PM 72751 articles. 3 followers. Follow

4 Replies

Similar Articles

[PageSpeed] 23

make the TR or TD a server controll

<td id="tdMyTD" runat="server">

THen in your repeater:



            System.Web.UI.HtmlControls.HtmlTableCell td = e.Item.FindControl("tdMyTD");
            td.Style.Add("color", "blue");

The Killer Ninja Coding Monkeys thank those that mark helpful posts as answers.

My Site | My Examples | My Blog

5/3/2006 10:49:10 PM
Thanks. I'll give that a try. I was just thinking of trying the PreRender event as well and using FindControl() at that point.

5/4/2006 7:59:12 PM
Here's my repeater:

<asp:Repeater ID="Repeater1" ... />
    <tr id="trTagOrder" style="font:Arial; font-variant:normal; color:Black;" runat="server" > 

In my PreRender, my tr object coming up NULL :

protected void Repeater1_PreRender(object sender, EventArgs e)
           HtmlTableRow tr = (HtmlTableRow)e.Item.FindControl("trTagOrder");

or in the ItemDataBound event:

protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
        HtmlTableRow tr = (HtmlTableRow)Repeater1.FindControl("trTagOrder");

What's up with that? I've done this a million times in a FormView Control's code-behind !
I'm sure I'm missing something here...
Thanks again,

5/4/2006 8:20:16 PM
Oops !!! I just added a check for Null !

This worked out :

    protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
        HtmlTableRow tr = (HtmlTableRow)e.Item.FindControl("trTagOrder");
        if (tr != null)
            tr.BgColor = "Green";


5/4/2006 8:33:07 PM

Similar Artilces:

how do you prevent a bunch of <tr><td></td></tr> from adding space to a table?
Hello, how do you prevent a bunch of <tr><td></td></tr> from adding space to a table? Thanks   Hello alex: > how do you prevent a bunch of <tr><td></td></tr> from adding space to a table? You need to get rid of blanks inside the td tags. In instance:    <td>      <img src="image.gif" />   </td> should be:    <td><img src="image.gif" /></td> For more control over code formatting, keep in mind that blanks *inside* a t...

Issue while assigning tr.innerHTML = "<td>a</td><td>b</td>";
tr = document.createElement('tr'); tr.innerHTML = "<td>a</td><td>b</td>"; print(tr.innerHTML); result:- "ab" expected:- "<td>a</td><td>b</td>" ...

Custom Composite Control
Let's start with what I'm looking for: <controls:MyWrapper id="Blah" runat="server">     <content>         <controls:Exporter id="Blah1" runat="server"  {This control has an image button and some other controls} />         <controls:GridView {This is a fully functional GridView} />         <controls:CustomFooterDetailer id="Yadda" runat="server" /> &nb...

How to hide a <td> in <table> in a repeater control?
I am using a Repeater control in which I am using a table. In table I have 4 <td> for headers in <Headertempale> and corresponding data in <Itemtemplate> of the Repeater. Now I want to hide one of the <td> of a table on a certain condition. <Repeater><HeaderTempalte><table>  <td><STRONG>View/Print</STRONG>  <td id="tdCopy"><asp:Label ID="LabelCopy" runat="server" text="Copy"></asp:Label></td>  <td><STRONG>Edit</STRONG></HeaderTempal...

Web Control with <abc:Control>TEXT HERE</abc:Control>
I'm trying to create a custom web control and support putting stuff in the middle - between the openning and closing tags:  <abc:Control>TEXT HERE</abc:Control> I would like to be able to put both text and other web controls between the tags. How do I do this? hi, why not the normal web user control? It also works fine. Maybe it is hard to create a control with the openning and closing tags...

[perl6/specs] 3cbe9d: change <em><em/> to <em></em>
----==_mimepart_51df5d3bc974_1ad7781dd81314a8 Date: Thu, 11 Jul 2013 18:34:51 -0700 Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-ID: <> Branch: refs/heads/master Home: Commit: 3cbe9d42b069d92c10c0621d71aaeddc5910c25f Author: timo <> Date: 2013-07-11 (Thu, 11 Jul 2013) Changed paths:...

Put a table (like <table><td></td></table>) in a Datagrid
Hello First of all, I just want to advise that I'll have many questions about datagrid for the next few days. I have to display a datagrid that seems very complicated for me (newbie in  So I display an image in my datagrid where the name of my image is in my datagrid's linked table. This is working fine. Now I would like to have a link like "Enlarge Image" below the image displayed. I guess that I need a table to do this to. I would like also to put a header text but I guess this is another question that I'll have to post later Thank you in advance for ...

Data control that outputs <div> and not <table >or <span>
 hi? i've been doing xhtml and css for a while and have just ventured into'm getting to grips with all the web controls but i have one problem.i want to be able to output a div layout for the data controls.the closest i have found is the datalist control that you can alter to output <span> instead of <table>is there any control that can output a <div> layout ? please point me in the right direction thanks  Hi, Panel should render as <DIV>, and if you use it in Repeater, you can do databinding etc. Repeater does not create markup...

>>>> Heads up <<<<
I just got a warning from Norton that "PamelaSetup-Basic.exe" has a virus in it. The name is "VirusBurst" Luckily, I did not install this software and Norton's quarantined it so I could delte it, which I have done. Symantec has not completed analysis of this particular piece of garbage but it did catch the sig. If you have installed Pamela, you may be in trouble. Duffy wrote: > I just got a warning from Norton that "PamelaSetup-Basic.exe" has a virus > in it. The name is "VirusBurst" > > Luckily, I did not install...

About the control <a> </a>
I have this code:   <style>    .ImagesMouseHover{     display:block;    font-size:80%;    text-align:center;     }   </style> Asp Code:     <td>                <a href="" class="ImagesMouseHover" onclick="ClickFunction">                &l...

data controls that output <div> and not <span> or <table> tags
 hi are there any controls that can output <div>?or can someone show me how to build my own controls for displaying data in div format?  Hi,use a Repeater control. Probably, haven't tested it myself, in .NET 3.5 you could also use the ListView for this.Grz, Kris. Read my blog. Handy Firefox plugins for web developers.Workaround for non working Mark as answer buttons....

 Hello,I want that my gridview should render <div> for all the elements like <table> ,<tr> and <td>How this can be done?Thanks,Deepes Verma Dont forget to click “Mark as Answer” on the post that helped you.This credits that member, earns you a point and mark your thread as Resolved for the sake of Future Readers. Can You Explian ur Question in details Rajeev Kumar TiwariMicrosoft Professional Hi Deepes, I think this could help you: the CSSAdapters you can control the HTML output. Kind regards,  T...

What a crap take control of my Window Genuine M$ <<<SIGH>>>
Just play yesterday with Comodo Memory Firewall Version 2.0 After reboot my Vista RED warning that my machine is not Genuine certificate from M$ ,I was shock...why??? Than I try to uninstall it,CTRPNL is not exist anymore + with ADMIN account too <<<SUCKS>>> THX God, I can open program and run the uninstaller, but after view reboots on my Sys.Tray still exist, YUCK. Now from my CTRPNL my Vista run the uninstall application >> Reboot >> open REGEDIT >>HKLM & HKCU_Software delete all Comodo Group,than go ...

superreview granted: [Bug 244569] Incorrect font style after <p></font> inside <table> inside <font> : [Attachment 204389] Potential patch
Johnny Stenback <> has granted Johnny Stenback <>'s request for superreview: Bug 244569: Incorrect font style after <p></font> inside <table> inside <font> Attachment 204389: Potential patch ...

Web resources about - Repeater Control: How to change change font color of <TR> or <TD> -

Resources last updated: 12/5/2015 5:46:10 AM