473,327 Members | 2,055 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,327 software developers and data experts.

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 945

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
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.