View Single Post
  #1 (permalink)  
Old July 10th, 2008, 11:32 PM
Deepeshk Deepeshk is offline
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