PC Review


Reply
Thread Tools Rate Thread

Coloring DataGrid Cells

 
 
Anthony Peterson
Guest
Posts: n/a
 
      29th Jan 2008
I'm trying to display the text in cells in red whenever the input is
invalid syntactically or out of the bounds of tolerance checks that
are run on the server. My datagrid doesn't use the row based Editing
system but instead has a save button for the whole datagrid and all
cells are text boxes.

I'm using the following code to finish up processing of my datagrid
(which is dynamically created on each postback) and in that code I
have tried to make these bad data cells red, but the cells stay the
same color. I'm looking for solutions to this problem, if possible.

internal void finishSetup(List<ScoresheetField> fields,
DataTable table)
{
dg.Width = Unit.Pixel(55 * fields.Count);
dg.DataSource = table;
BindData();

foreach (InvalidDatum d in InvalidData.Data)
{
if (d.IsSyntaxProblem)
((TextBox)dg.Items[d.RowIndex].Cells[d.CellIndex].FindControl(fields[d.CellIndex].fieldName)).ForeColor
= System.Drawing.Color.Red;
else
((TextBox)dg.Items[d.RowIndex].Cells[d.CellIndex].FindControl(fields[d.CellIndex].fieldName)).ForeColor
= System.Drawing.Color.Purple;
}
}

InvalidData.Data is a static member of that class that is filled
during Tolerance checking with a InvalidDatum object for each case of
bad syntax and data outside its Tolerances (for instance, Ph less than
3)
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Coloring Cells Ron2490 Microsoft Excel Misc 1 2nd Aug 2010 07:36 PM
Re: datagrid row coloring Ron Microsoft C# .NET 0 10th Sep 2004 09:59 PM
Re: datagrid row coloring sandman Microsoft C# .NET 0 10th Sep 2004 03:12 PM
coloring the row in a datagrid usha Microsoft Dot NET Framework Forms 1 16th Jul 2004 03:47 PM
Coloring of Rows and particular cells in Datagrid C# Windows Forms Mahesh Rane Microsoft Dot NET Framework Forms 1 17th Sep 2003 11:59 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:23 PM.