473,387 Members | 1,766 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,387 software developers and data experts.

Changing DataGrid Item BGCOLOR

JC
Is there a way to change the background color of a specific item in a datagrid based on it's value? For example, assuming I have the following table layout

genr
son
lengt

If the genre is 'Rock' then I would like to give the row a different color than if the genre is 'Rap'. It seems like this would be a pretty common desire, but I haven't been able to find any documentation on it, and today I've rammed my head against the wall trying to figure out how to do this

I've tried using template columns, but I cannot get it to work to save my life... Is there a way to do this? If I cannot change the color of the entire row is there at least a way to change the bgcolor of the actual genre item based on it's value

Any input or suggestions would be highly appreciated. Or if you can point me to any helpful links I would be delighted

Thanks
JC
Nov 18 '05 #1
1 1100
JC
Ok, finally figured it out by doing a switch on e.Item.Cells[the_column] in the ItemDataBound event, and setting the Item.BackColor that way.
Nov 18 '05 #2

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

Similar topics

1
by: Mike Irwin | last post by:
I'm trying to add an attribute to each column header of a DataGrid. I know that I need to do this within the ItemCreated event of the DataGrid, but I'm stuck on how to go any further. I found...
8
by: Sue | last post by:
I have a datagrid populated with 6 visible read-only labels and several hidden fields. Below the datagrid, I have a table with various textboxes, dropdowns, etc. I've managed to decypher the...
3
by: simon | last post by:
I have dataGrid. I would like that item background(row of the dataGrid) is red if the active field in database is false otherwise leave it like it is. I tried like this: <asp:DataGrid...
1
by: Michael M | last post by:
Hi I am trying to add mouseover property to asp:datagrid in the asp .net page My pag So the output in HTML for a row should look like <tr style="onmouseover=this.bgcolor=#ff0000;...
1
by: Harry Devine | last post by:
I have a DataGrid that is configured to use the Edit/Update/Cancel concept correctly. My grid shows values from 5 database fields. I only need to update that last 4 fields. The last field is a...
0
by: Danny | last post by:
I am trying to sort my second datagrid. And it works but only after i click 2 times on the column header. The first time i click on the header the data in the right order will add to the rows in...
1
by: jason | last post by:
The guts of the below asp.net vb code was pieced together from another thread - all due credit to it's original author. Thank you! I've modified it to maintain a small local Microsoft 2000...
1
by: John Bayly via .NET 247 | last post by:
I'm working on an inherited Datagrid class that includes afunction called onMouseMove to paint the row under the cursor tomake reading easier for users. To paint the row, the function sets the...
0
by: jigsawcube1 | last post by:
I am trying to accept two input strings and concatinate and display the result in a datagrid. Following is the HTML and code. ItemCommand does not get fired what is that I am missing? <body...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.