Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics 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
 
 
Thread Tools Search this Thread Display Modes
  #31 (permalink)  
Old April 15th, 2010, 07:02 AM
Registered User
 
Join Date: Mar 2010
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

My ItemDataBound event doesn't seem to fire? Do I have my query within the wrong event?

Thanks.
  #32 (permalink)  
Old April 15th, 2010, 10:25 AM
Registered User
 
Join Date: Mar 2010
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Did you receive my last posts? I think the web site was down for a while.

Thanks.
  #33 (permalink)  
Old April 15th, 2010, 04:50 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Take a look at this:

Traders myTraders = dataItem.DataItem as Traders;

Your DataItem is probably not a Traders instance. As such, the conversion fails, and myTraders remains null. This in turn means the control is never bound.

What do you see when you debug? That would be the way to figure these thing out. Because of the database dependency, I can't help much, other than tell you where to look for potential problems.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
  #34 (permalink)  
Old April 16th, 2010, 04:51 AM
Registered User
 
Join Date: Mar 2010
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

That's my whole problem - I can't debug my ItemDataBound event as the error is occuring within my OnSelecting event, i.e. before my ItemDataBound event is fired. Can you think of any reason why your control would act this way bound to a linqdatasource instead of an objectdatasource? Thanks.
  #35 (permalink)  
Old April 16th, 2010, 05:15 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

You could try calling DataBind on your List or DataSource control manually in an earlier event, like Page_Load. Apparently when the control starts binding the life cycle is in Databinding mode and then my control does its checks.

Alternatively, you could remove the check in the control and not throw an error.

Again, since I don't have a reproducible scenario, I cannot test this for you. I also don't have the time to build a sample project and try to reproduce this for you. So, unless you send me a complete sample project, there's not much I can do for you.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
  #36 (permalink)  
Old April 16th, 2010, 06:03 AM
Registered User
 
Join Date: Mar 2010
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

How would I remove the check in your control and not throw the error?

Thanks again.
  #37 (permalink)  
Old April 16th, 2010, 06:21 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

What about deleting the lines that do the check and throw the exception?

Not trying to be funny, but if you look at the code, it should be easy to see where this check is made and the error is thrown....

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
  #38 (permalink)  
Old April 19th, 2010, 05:56 AM
Registered User
 
Join Date: Mar 2010
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Imar,

I managed to delete the lines in your control that do the check and throw the exception but as predicted this led to other issues, i.e. within your RattingSettings class your rateItems variable is now null, which will be due to the fact that the ItemId cannot be found from the data source. Basically I cannot figure out a way to provide your control within my listview with an ItemId before I bind my listview, i.e. ContentRating1.DataSource must be bound before my listview has been bound but ContentRating1 requires the rating values returned from my listview's bound query - it's a bit of a catch 22!

Thanks.
  #39 (permalink)  
Old April 20th, 2010, 05:09 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Like I said, I can't help you if you don't give me a reproducible and representable scenario. The C# example using classes was reproducible, but not representable.

I am sure this is all relatively easy to fix; it shouldn't take weeks. However, since I don't know what the problem is I can't fix it.

If you can, zip a fully working example (with just the files and tables needed) using your database schema, data, etc and either mail it to me or provide a download link somewhere. Then next week I'll be able to take look (on vacation now).

As I suggested earlier, did you try explicit binding in Page_Load? What happended when you try that?

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
  #40 (permalink)  
Old April 20th, 2010, 06:57 AM
Registered User
 
Join Date: Mar 2010
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Imar,

Sorry I interrupted your vacation!

Unfortunately, I am already calling my Bind methods from my page load event.

If you find the time please navigate to the below address where you can download my ListView_Rating.zip file which holds my test web site. Simply extract and open the web site through VS 2008. You will have to have sql server 2008 express installed for it to work....

http://www.tradeselector.co.uk/Misc/ListView_Rating.zip

Thanks again.
 


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
Populate a ASP.Net Treeview control dotnetDeveloper ADO.NET 2 November 21st, 2008 07:25 AM
how to use asp.net we user control on asp 3.0 web i_shahid Java Basics 2 January 8th, 2008 09:04 AM
using asp.net web user control in asp 3.0 App i_shahid Classic ASP Professional 0 January 8th, 2008 07:32 AM
Control in ASP.NET Manisha0605 .NET Framework 2.0 1 March 29th, 2007 02:33 PM
XML use in ASP (pre .NET) Lucky Bastard Classic ASP XML 0 April 7th, 2005 11:08 PM



All times are GMT -4. The time now is 01:03 AM.


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