Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / DataGrid / August 2006

Tip: Looking for answers? Try searching our database.

Setting color for a single cell in a datagrid.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
UJ - 28 Aug 2006 18:42 GMT
How can I set the background color for a single cell dynamically in a
datagrid control? I know how to do the entire row but not the cell.

TIA - Jeff.
Eliyahu Goldin - 29 Aug 2006 09:24 GMT
You need first to navigate to the cell and then set its BackColor property.
Navigation to cell depends on in what place in the code you want to do it.
If you are in the ItemDataBound event, which is the most common place for
handling this sort of tasks, you get a reference to the datagrid item (row)
as a parameter and you can use Cells collection to get to the cell. In
PageLoad or PreRender event you first navigate to the row in the grid and
then to the cell.

Signature

Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]

> How can I set the background color for a single cell dynamically in a
> datagrid control? I know how to do the entire row but not the cell.
>
> TIA - Jeff.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.