Hi all,
I want to change the colour of an item in a datagrid depending on its date. I have found that this event is the right one but the code at bottom of email (extracted from ms-help://MS.VSCC/MS.MSDNVS/vbcon/html/.....)
appears to generate the error
Server Error in /fileupload Application.
--------------------------------------------------------------------------------
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
source code in c#
private void DataList1_ItemDataBound(object sender,
System.Web.UI.WebControls.DataListItemEventArgs e)
{
DataRowView drv = (DataRowView)(e.Item.DataItem);
int quantity = int.Parse(drv.Row["Quantity"].ToString());
if (quantity < 10)
{
e.Item.BackColor = Color.Red;
}
}
P.S. I have of course changed the function from DataGrid to DataList but this must be supported since Visual Studio produces the function definition
Best wishes,
Grahame
Grahame Hambleton
Webmaster / Developer
Saïd Business School
University of Oxford
Saïd Business School
Park End Street
Oxford OX1 1HP
Tel: +44 (0) 1865 288863
Fax: +44 (0) 1865 288805
email:
[email protected]
http://www.sbs.ox.ac.uk