Wrox Programmer Forums
|
Wrox Book Feedback A forum to submit feedback on Wrox books if other forums on P2P have been unable to address your book-specific needs. IF YOU ARE LOOKING FOR CODE DO NOT ASK "Where can I find the code for this book?" That question is answered here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Wrox Book Feedback section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old January 7th, 2011, 06:12 AM
Registered User
 
Join Date: Jan 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default PlanetWrox - Small bug in code

Hello.

I have recently been through the book Beginning ASP.NET 4 in C# and VB and have found a small bug in the code of the www.PlanetWrox.com web site (i.e. built from the book).

On the Gig Pics page, when you select an item from the drop down list that has more than 3 pictures (i.e. more than one page), go to the next or last page (Next or Last button), then select an album with up to 3 pictures (i.e. one page), the ListView control shows "No data was returned".

For example -
1) go to www.planetwrox.com
2) Select Gig Pics from menu
3) Select Pam's Pics from drop down
4) Click the "Last" button
5) Select Bubba Lines from the dropdown - "No data was returned" is shown
6) Select Brothers In Arms from dropdown - Album cover pic shows
7) Re-select Bubba Lines from dropdown - now we see a pic of Mr Incredible

I presume that there's a nice easy fix for this... some C# code for the dropdown On Select method to initialise the ListView, perhaps.

I would really appreciate it if someone could advise.

Many thanks.

Last edited by RiversideAce; January 7th, 2011 at 06:24 AM..
Reply With Quote
  #2 (permalink)  
Old January 7th, 2011, 08:39 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Yes, you're correct. This is indeed a problem.
Quote:
I presume that there's a nice easy fix for this... some C# code for the dropdown On Select method to initialise the ListView, perhaps
And that's indeed the fix. For a detailed explanation, check out this post:

http://leedumond.com/blog/resetting-...in-a-listview/

The following should do the trick:

Code:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
  CommandEventArgs commandEventArgs = new CommandEventArgs("First", "");
  DataPager pager = ListView1.FindControl("DataPager1") as DataPager;
  if (pager != null)
  {
    NextPreviousPagerField nextPreviousPagerField = pager.Fields[0] as NextPreviousPagerField;
    if (nextPreviousPagerField != null)
    {
      nextPreviousPagerField.HandleEvent(commandEventArgs);
    }
  }
}
This also requires the following addition to the DropDownList in markup:

Code:
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="EntityDataSource1" DataTextField="Name" DataValueField="Id" onselectedindexchanged="DropDownList1_SelectedIndexChanged" />
For future posts like these, you're better off posting in the book's own forum category: http://p2p.wrox.com/book-beginning-asp-net-4-c-vb-560/

Hope this helps,

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!
Reply With Quote





Similar Threads
Thread Thread Starter Forum Replies Last Post
ch06 source code bug rdfield BOOK: Professional XMPP Programming with JavaScript and jQuery 2 December 29th, 2011 05:52 PM
A small problem with the code from CH06 and with next ones. Jeremie BOOK: ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solutio 2 February 15th, 2009 07:40 AM
a big bug on a code busteronline ASP.NET 1.0 and 1.1 Basics 0 September 15th, 2008 09:11 AM
Need help with a small piece of code (New to VB) kwik10z Excel VBA 2 October 12th, 2007 06:46 AM
small C++ game code PLEASE HELP!!! ands122 C++ Programming 2 June 18th, 2005 04:55 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.