Input string was not in a correct format. RRS feed

  • Question

  • User-826886425 posted

    I've created pic album using list view 

    when i run the page i got the following error 


    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: 

    Line 25:         </GroupTemplate>
    Line 26:         <ItemTemplate>
    Line 27: <asp:Image Line 28:             id="picAlbum" runat="server" AlternateText='<% #Eval("picture_tag") %>'
    Line 29:             ImageUrl='<%# "photoHandler.ashx?id=" + Eval("pic_id") %>' />

    Source File: C:\Users\RTG\Documents\Visual Studio 2012\WebSites\Musa\photogallary.aspx    Line: 27 

    Stack Trace: 

    [FormatException: Input string was not in a correct format.]
       Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble(String Value, NumberFormatInfo NumberFormat) +181
       Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(String Value, NumberFormatInfo NumberFormat) +63
    [InvalidCastException: Conversion from string "photoHandler.ashx?id=" to type 'Double' is not valid.]
       Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(String Value, NumberFormatInfo NumberFormat) +207
       Microsoft.VisualBasic.CompilerServices.Operators.AddObject(Object Left, Object Right) +478
       ASP.photogallary_aspx.__DataBinding__control15(Object sender, EventArgs e) in C:\Users\RTG\Documents\Visual Studio 2012\WebSites\Musa\photogallary.aspx:27
       System.Web.UI.Control.OnDataBinding(EventArgs e) +92
       System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +85
       System.Web.UI.Control.DataBind() +15
       System.Web.UI.Control.DataBindChildren() +187
       System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +94
       System.Web.UI.Control.DataBind() +15
       System.Web.UI.WebControls.ListView.CreateItemsInGroups(ListViewPagedDataSource dataSource, Boolean dataBinding, InsertItemPosition insertPosition, ArrayList keyArray) +1150
       System.Web.UI.WebControls.ListView.CreateChildControls(IEnumerable dataSource, Boolean dataBinding) +768
       System.Web.UI.WebControls.ListView.PerformDataBinding(IEnumerable data) +44
       System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +123
       System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +33
       System.Web.UI.WebControls.DataBoundControl.PerformSelect() +138
       System.Web.UI.WebControls.ListView.PerformSelect() +101
       System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +30
       System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +105
       System.Web.UI.WebControls.ListView.CreateChildControls() +55
       System.Web.UI.Control.EnsureChildControls() +83
       System.Web.UI.Control.PreRenderRecursiveInternal() +42
       System.Web.UI.Control.PreRenderRecursiveInternal() +168
       System.Web.UI.Control.PreRenderRecursiveInternal() +168
       System.Web.UI.Control.PreRenderRecursiveInternal() +168
       System.Web.UI.Control.PreRenderRecursiveInternal() +168
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +974
    Saturday, June 1, 2013 11:51 AM

All replies

  • User1992938117 posted

    Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble(String Value, NumberFormatInfo NumberFormat) +181

    From error it looks you are trying to Convert a value to Double but that value is a character and can not converted to a double, Do something as below in your handler code.

     string querySqlStr = "";
            if (context.Request.QueryString["id"] != null)
                querySqlStr = "select * from photp where id=" + context.Request.QueryString["id"];
                querySqlStr = "select * from photo";

    It would be helpful if we can see your handler code.

    Saturday, June 1, 2013 2:44 PM
  • User753101303 posted


    Try "photoHandler.ashx?id=" & Eval("pic_id")

    Seems you are using VB and trying to add a string and a numeric value which tries to convert the string value to a double which is what fails.  & is the string concatenation so rather than trying to convert "photoHandler.ashx?id="  to a numeric value it will convert Eval("pic_id") to a string.

    Thursday, March 17, 2016 7:46 AM