Set Text Color by Column in a Repeater Control

G

Guest

I have a Repeater control bound to a DataSet that creates a table with 6
columns. The text displayed in one of the columns may need to be set to grey
instead of black.

The DataSet is held and manipulated in a separate class "ResponseData.cs".
This class has a method ".getTextColor(int whichColumn)", which will return a
HEX value for the text color.

In JSP, a simple solution would have been to add inline code e.g.
style="color: <%= responseData.getTextColor(x) %>". How can I get to the
style attribute in the table the Repeater builds and set the text color in
ASP.Net (1.1)?

Thank you.
 
J

Jeffrey Palermo [MCP]

Use the ItemDataBound event that fires after the data has been bound. Use
this to get a handle to the current row. Then set the colors for all the
cells. When it's finished rendering, it'll look how you want. Note that in
your declarative repeater definition, you'll want to use <asp:TableCell>
controls so you can FindControl on the id and get the right cell. Then you
can use .Attributes["style"] = . . .

Best regards,
Jeffrey Palermo
 
G

Guest

Thank you, I will try this.

Jeffrey Palermo said:
Use the ItemDataBound event that fires after the data has been bound. Use
this to get a handle to the current row. Then set the colors for all the
cells. When it's finished rendering, it'll look how you want. Note that in
your declarative repeater definition, you'll want to use <asp:TableCell>
controls so you can FindControl on the id and get the right cell. Then you
can use .Attributes["style"] = . . .

Best regards,
Jeffrey Palermo

ASP Yaboh said:
I have a Repeater control bound to a DataSet that creates a table with 6
columns. The text displayed in one of the columns may need to be set to grey
instead of black.

The DataSet is held and manipulated in a separate class "ResponseData.cs".
This class has a method ".getTextColor(int whichColumn)", which will return a
HEX value for the text color.

In JSP, a simple solution would have been to add inline code e.g.
style="color: <%= responseData.getTextColor(x) %>". How can I get to the
style attribute in the table the Repeater builds and set the text color in
ASP.Net (1.1)?

Thank you.
 

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

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top