473,396 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Set Text Color by Column in a Repeater Control

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.
Nov 18 '05 #1
2 2356
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" <AS******@discussions.microsoft.com> wrote in message
news:BD**********************************@microsof t.com...
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.

Nov 18 '05 #2
Thank you, I will try this.

"Jeffrey Palermo [MCP]" wrote:
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" <AS******@discussions.microsoft.com> wrote in message
news:BD**********************************@microsof t.com...
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.


Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Ben R. | last post by:
I've got a repeater that's bound to a datareader and I'd like to conditionally modify the text that is being outputted. Previously, I've done this by assigning a name to attribute to the...
1
by: Mike | last post by:
When using a repeater control I want to get the database value by index instead of using the column name. How can I do this? My current repeater code looks like this: <asp:repeater...
0
by: Reza Nabi | last post by:
Dear All: Banckgroud: I have a datagrid which lives inside a repeater. Which is working fine. What i need is to dyanamically set the column width of the grid (which lieves inside the repeater)....
5
by: Matt Jensen | last post by:
Am I right in saying that you can't have a Radiobutton web control inside a repeater bound to a database datasource and (inline) dynamically set it's ID and text properties from the repeaters rows?...
14
by: Joe | last post by:
Hello All: I am trying to dynamically populate a web page with literal content and controls (textboxes and checkboxes (and eventually two buttons - the buttons do not appear in the code yet). I...
1
by: sck10 | last post by:
Hello, I am inserting the values for radio buttons on a form into a database. There are 25 questions with 4 possible answers (see below). Is it possible to pragmatically build the radio button...
3
by: Charlie | last post by:
Hi: Is it possible to databind an image in Repeater Control? I see support for it in GridView, but not in Repeater control. There is another way to do this, but would rather go with new...
2
by: mark4asp | last post by:
This page is currently using a Repeater control to create a table with 6 columns. The first column has 2 ImageButton controls and a common header. How can I do this with a DataGrid ? I need...
1
by: =?Utf-8?B?Um9iZXJ0IFNtaXRo?= | last post by:
Hi, I have a repeater control with rows in made of of link buttons so that they react to a click as below: <div> <ASP:Repeater id="rptUserList" runat="server"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.