This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_001_01C21C35.B4002CF0
Content-Type: text/plain; charset="iso-8859-1"
Hi all,
I have a datagrid and wish to format individual cells depending on the value
in them - eg >0 <0 or =0. The method I used to attempt this was to databind
the grid and then access the DataGridItem collection.
After calling the databind() method, I tested the content of the cells
collection like so...
public void TestOutput(DataGrid dg)
{
Response.Write("<Table>");
foreach (DataGridItem dgi in dg.Items)
{
Response.Write ("<tr>");
foreach (TableCell tc in dgi.Cells)
{
Response.Write ("<td>" + tc.Text + "</td>");
}
Response.Write ("</tr>");
}
Response.Write ("</Table>");
Response.End();
}
...only to find that the value of each cells text is blank.
My alternative is to use the grids itemCreated event along the lines of
below, using the datarow info to set the table row.
DataItem.Row.ItemArray[0] - the data row
e.Item.Cells[0].BackColor - the table row
However, I have a number of columns that are in the data row but won't be
displayed in the table row - this means I have to hardcode the relationship
between the data structure and the table display. So if I ever want to
change the order of the columns, I have to change all the code logic as well
:-(
I have two questions, why doesn't my original method work and what is the
best solution for this problem?
Thanks in advance,
Matt
"This communication is intended solely for the addressee and is confidential and not for third party unauthorised distribution."