Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 30th, 2003, 07:17 AM
Authorized User
 
Join Date: Jun 2003
Location: Oxford, Oxfordshire, United Kingdom.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default Datagrid ItemDataBound Event Problem

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: grahame.hambleton@sbs.ox.ac.uk
http://www.sbs.ox.ac.uk
__________________
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: grahame.hambleton@sbs.ox.ac.uk
http://www.sbs.ox.ac.uk
Reply With Quote
  #2 (permalink)  
Old December 3rd, 2011, 03:10 AM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Thumbs up

I had to load my reader into a datatable first, then set the repeater's datasource to the datatable. Then everything worked fine.

Thanks

Please check the link bellow:
http://forums.asp.net/t/1187140.aspx
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ItemDataBound to Grid Within Repeater rstelma ASP.NET 2.0 Professional 4 July 9th, 2008 02:45 AM
Confirm in ItemDataBound rstelma ASP.NET 1.0 and 1.1 Basics 3 December 6th, 2006 02:10 AM
Datagrid ItemDataBound column widht eresina ASP.NET 1.0 and 1.1 Basics 0 August 10th, 2005 04:42 AM
DataGrid ItemDataBound Wyatt70 ADO.NET 2 November 22nd, 2004 03:31 PM



All times are GMT -4. The time now is 12:39 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.