473,473 Members | 2,036 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Problem with background color of row in datagrid

Hi Folks,

I've been searching the Google groups for a couple of hours now, and the
solution to my problem (setting the color of datagrid rows during runtime):

public class LocalizedDataGrid : System.Web.UI.WebControls.DataGrid
{
protected override void OnInit(EventArgs e)
{
this.ItemCreated+=new
DataGridItemEventHandler(LocalizedDataGrid_ItemCre ated);
base.OnInit(e);
}
protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
this.CellPadding = 5;
this.BorderWidth = 0;
base.Render (writer);
}

private void LocalizedDataGrid_ItemCreated(object sender,
DataGridItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
e.Item.BackColor = System.Drawing.Color.Red;
}
}

But for some reason my background color of the rows stays white.

Any suggestions?

Greets,
Gab

Nov 18 '05 #1
0 948

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

Similar topics

1
by: Stanley Alex | last post by:
I am having a problem with the way my DataGrid displays when a column header is clicked on to sort the records (AllowSorting="True"). When the column name is clicked, a white background appears...
1
by: IntraRELY | last post by:
I am having an issue giving a page with a datagrid a background color. Is there something I am missing, I dont seem to have a problem when there is no datagrid and every page there is one I cannot...
0
by: Stanley Alex | last post by:
I am having a problem with the way my DataGrid displays when a column header is clicked on to sort records. When the column name is clicked, a white background appears behind the column name. Also,...
0
by: Gabriël van der Kruijk | last post by:
Hi Folks, I've been searching the Google groups for a couple of hours now, and the solution to my problem (setting the color of datagrid rows during runtime): public class LocalizedDataGrid :...
7
by: PJ | last post by:
How can you set the background color of individual columns in a datagrid to be different to others? The table styles only allow you to do this at the grid level for all columns.
1
by: Michael Turner | last post by:
Anyone know if you can add a background image to a datagrid, there is a property for colour but not for an image.
2
by: Multithreading problem in vb.net | last post by:
Greetings, I am new to multithreading and I am trying to implement it in my app. This application is distributed application which needs to refresh every say 5 secs to show some activities in...
1
by: Brock | last post by:
Thanks in advance... (you can see a screenshot of what my form looks like currently at http://www.juggernautical.com/DataGrid.jpg - the Datalist is super-imposed in 'design view' but the DataGrid...
2
by: =?Utf-8?B?Y3JlYXZlczA2MjI=?= | last post by:
I have a nested datagrid in a xaml file, the parent datagrid loads the vendor information and the details loads the documents for that vendor in a datagrid. Everything is working fine until I click...
9
by: mcfly1204 | last post by:
I have a windows forms application, currently with a datagrid, that I would like to dynamically change the background color on a row by row basis based off of values in child rows. Parent rows are...
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
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...
1
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
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.