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 > BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 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 July 10th, 2008, 11:32 PM
Registered User
 
Join Date: Jul 2008
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 12 (page 400) Try It Out: Applying Filter

Hi,

I tried this code, and it shows up an error

Please help, i am completely new to asp.net

Later when i deleted the row <asp:ListItem>"Please make your choice"</asp:ListItem> it ran perfectly, was this the cause of error?


Deepesh

<%@ Page Language="VB" MasterPageFile="~/MasterPages/ManagementMaster.master" AutoEventWireup="false" CodeFile="Reviews.aspx.vb" Inherits="Reviews" title="Planet Wrox - Management Reviews" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" Runat="Server">
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:DropDownList ID="DropDownList1" runat="server" AppendDataBoundItems="True"
        AutoPostBack="True" DataSourceID="SqlDataSource1" DataTextField="Name"
        DataValueField="ID">
                <asp:ListItem>"Please make your choice"</asp:ListItem>
            </asp:DropDownList>
            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
                DataKeyNames="Id" DataSourceID="SqlDataSource2"
                style="font-family: Arial, Helvetica, sans-serif; font-size: small">
                <Columns>
                    <asp:BoundField DataField="Id" HeaderText="Id" InsertVisible="False"
                        ReadOnly="True" SortExpression="Id" />
                    <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
                    <asp:BoundField DataField="Summary" HeaderText="Summary"
                        SortExpression="Summary" />
                    <asp:BoundField DataField="Body" HeaderText="Body" SortExpression="Body" />
                    <asp:BoundField DataField="GenreId" HeaderText="GenreId"
                        SortExpression="GenreId" />
                    <asp:CheckBoxField DataField="Authorized" HeaderText="Authorized"
                        SortExpression="Authorized" />
                    <asp:BoundField DataField="CreateDateTime" HeaderText="CreateDateTime"
                        SortExpression="CreateDateTime" />
                    <asp:BoundField DataField="UpdateDateTime" HeaderText="UpdateDateTime"
                        SortExpression="UpdateDateTime" />
                </Columns>
            </asp:GridView>
            <asp:SqlDataSource ID="SqlDataSource1" runat="server"
                ConnectionString="<%$ ConnectionStrings:PlanetWroxConnectionString1 %>"
                SelectCommand="SELECT [Id], [Name] FROM [Genre] ORDER BY [SortOrder]">
            </asp:SqlDataSource>
            <asp:SqlDataSource ID="SqlDataSource2" runat="server"
                ConnectionString="<%$ ConnectionStrings:PlanetWroxConnectionString1 %>"
                SelectCommand="SELECT * FROM [Review] WHERE ([GenreId] = @GenreId)">
                <SelectParameters>
                    <asp:ControlParameter ControlID="DropDownList1" Name="GenreId"
                        PropertyName="SelectedValue" Type="Int32" />
                </SelectParameters>
            </asp:SqlDataSource>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
============================
Error Message below
====================
Server Error in '/WebSite1' Application.
Input string was not in a correct format.
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.FormatException: Input string was not in a correct format.

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.

Stack Trace:

[FormatException: Input string was not in a correct format.]
   System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +2755599
   System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +112
   System.String.System.IConvertible.ToInt32(IFormatP rovider provider) +43
   System.Convert.ChangeType(Object value, TypeCode typeCode, IFormatProvider provider) +293
   System.Web.UI.WebControls.Parameter.GetValue(Objec t value, String defaultValue, TypeCode type, Boolean convertEmptyStringToNull, Boolean ignoreNullableTypeChanges) +264
   System.Web.UI.WebControls.Parameter.get_ParameterV alue() +66
   System.Web.UI.WebControls.ParameterCollection.GetV alues(HttpContext context, Control control) +254
   System.Web.UI.WebControls.SqlDataSourceView.Initia lizeParameters(DbCommand command, ParameterCollection parameters, IDictionary exclusionList) +274
   System.Web.UI.WebControls.SqlDataSourceView.Execut eSelect(DataSourceSelectArguments arguments) +754
   System.Web.UI.DataSourceView.Select(DataSourceSele ctArguments arguments, DataSourceViewSelectCallback callback) +17
   System.Web.UI.WebControls.DataBoundControl.Perform Select() +149
   System.Web.UI.WebControls.BaseDataBoundControl.Dat aBind() +70
   System.Web.UI.WebControls.GridView.DataBind() +4
   System.Web.UI.WebControls.BaseDataBoundControl.Ens ureDataBound() +82
   System.Web.UI.WebControls.CompositeDataBoundContro l.CreateChildControls() +69
   System.Web.UI.Control.EnsureChildControls() +87
   System.Web.UI.Control.PreRenderRecursiveInternal() +50
   System.Web.UI.Control.PreRenderRecursiveInternal() +170
   System.Web.UI.Control.PreRenderRecursiveInternal() +170
   System.Web.UI.Control.PreRenderRecursiveInternal() +170
   System.Web.UI.Control.PreRenderRecursiveInternal() +170
   System.Web.UI.Control.PreRenderRecursiveInternal() +170
   System.Web.UI.Control.PreRenderRecursiveInternal() +170
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2041


Reply With Quote
  #2 (permalink)  
Old July 12th, 2008, 04:18 AM
Imar's Avatar
Wrox Author
Points: 72,045, Level: 100
Points: 72,045, Level: 100 Points: 72,045, Level: 100 Points: 72,045, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,083
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi Deepesh,

Take a look at step 9 on page 402:
Quote:
quote:Save all your changes and open Reviews.aspx in your browser. If you get an error, ensure that you set the Value of the static ListItem in the drop-down list to an empty string (“”).
Step 10 on page 400 shows this as well. Looks like you forgot that step as your ListItem looks like this:
Code:
<asp:ListItem>"Please make your choice"</asp:ListItem>
instead of this:
Code:
<asp:ListItem Value="">Please make your choice</asp:ListItem>
Without the empty value attribute, the text Please make your choice is used as the drop down's value. This text cannot be converted to an Integer to be passed SelectParameters for the DataSource and thus you get the error you posted.

Hope this helps,

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
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
Chapter 12 Try It Out: Applying Filter (pg 400) Deepeshk ASP.NET 3.5 Basics 2 July 12th, 2008 10:28 AM
Chapter 12: Page 410 - Try it out VeganMan BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 April 20th, 2008 03:44 PM
Chapter 5 Applying themes to Page Try it Out mcauliff BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 0 October 3rd, 2007 11:04 AM
Automatically Applying Advanced Filter / Sort bridog39 Access 4 November 24th, 2005 04:18 PM



All times are GMT -4. The time now is 11:11 PM.


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