Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 1.1
This is the forum to discuss the Wrox book Beginning ASP.NET 1.1 with Visual C#.NET 2003 by Chris Ullman, John Kauffman, Chris Hart, Dave Sussman, Daniel Maharry; ISBN: 9780764557088
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 1.1 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
 
Old September 11th, 2004, 09:34 AM
Registered User
 
Join Date: Sep 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default For Each structure - Ch04

Page 157: This doesn't jive with the file T10-ForEach.aspx which is in the downloaded code. Running the file returns the error:

"BC32023: Expression is of type 'System.Web.UI.WebControls.ListBox', which is not a collection type."

The whole file is small:

[code]
<%@ Page Language="vb" %>
<script runat="server">

    Sub Page_Load()
       If IsPostBack
       Dim Cities as object

       lblMessage.text = "we will send you information on these cities:"
       For Each Cities in lstCities
         lblMessage.text += Cities.Value & "<br/>"
       Next
       End If
    End Sub

</script>
<html>
<head>
    <title>For Next Example</title>
</head>
<body>
    <form runat="server">
    <asp:Label runat="server" ID="lblMessage"/>
        Select all the cities that interest you: <br />
        <asp:listbox id="lstCities" runat="server">
            <asp:listitem>England</asp:listitem>
            <asp:listitem>Holland</asp:listitem>
            <asp:listitem>Norway</asp:listitem>
            <asp:listitem>Portugal</asp:listitem>
            <asp:listitem>Spain</asp:listitem>
        </asp:listbox>
        <br />
        <input type="submit" value="Submit Query" />
    </form>
</body>
</html>
[Code]

I've been playing with the file to get it to do something but can't figure it out. Is this one for the Errata form, or can someone help me with the file?
Thanks,
Steve



 
Old September 13th, 2004, 07:37 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

WHere is your problem, is it this line: For Each Cities in lstCities

Try this: For Each City As ListItem in lstCities.Items

Brian





Similar Threads
Thread Thread Starter Forum Replies Last Post
Ch04 TIO Pg 111 Error lollivier BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 4 February 14th, 2006 11:31 AM
Database Structure aw23 VB Databases Basics 2 October 15th, 2005 01:20 PM
how to write a structure??? keepsmiling_sruti VB How-To 1 July 4th, 2005 11:09 PM
[CH04] Interfaces Norm 2782 BOOK: Professional PHP 5 ISBN: 978-0-7645-7282-1 3 June 16th, 2005 04:56 AM
How to structure query mkaufman SQL Language 6 June 10th, 2003 01:52 PM





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