Input String Was Not In Correct Format VS.Net 2.0

Posted on 2006-03-23
Last Modified: 2011-10-03

I am using a gridview to display records with a hyperlink to the detail page.  In the previous version the datagrid contained a field in which you entered the parameter value you wanted to pass.  I don't see one in this control, so how do I properly set the control to pass the following information in the querystring (or is this even correctly written):

Also, I noticed in the page load on my Results.aspx page, that the QueryString value is NULL even though it displays the proper value in the address bar.  At what point is the QueryString available?  My app is written in ASP.Net 2.0 in C#.

Question by:FoxProMari
    LVL 9

    Accepted Solution

    try this:

                                NavigateUrl='<%# Eval("KBID", " Results.aspx?KBID={0}") %>'
    LVL 12

    Assisted Solution

    you can also do NavigateUrl='<%# "Results.aspx?KBID=" & Container.DataItem("KBID") %>'

    which one you choose is pretty much up to personal preference.

    Author Comment

    Maybe I'm putting the code in the wrong place - I tried putting it into the NavigateURL box by Selecting "Edit Columns".  I received the following message:
    GridView - GridView1
    There was an error rendering the control.  Databinding expressions are only supported on objects that have a DataBinding event.  System.Web.UI.WebControls.HyperLinkField does not have a DataBinding Event.

    When to enter it directly into the html page it said I can't use a code block there.

    Prior to attempting to retrieve the KBID from the querystring the page after loading would display this URL:
    The KBID values change as appropriate but this command in Results.aspx page load returned a null value:
                  KBID = Convert.ToInt32(Request.QueryString["KBID"]

    The exact exception is as follows:
    [FormatException: Input string was not in a correct format.]
       System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +2753507
       System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +102
       System.String.System.IConvertible.ToInt32(IFormatProvider provider) +43
       System.Convert.ChangeType(Object value, TypeCode typeCode, IFormatProvider provider) +293
       System.Web.UI.WebControls.Parameter.GetValue(Object value, String defaultValue, TypeCode type, Boolean convertEmptyStringToNull, Boolean ignoreNullableTypeChanges) +257
       System.Web.UI.WebControls.Parameter.get_ParameterValue() +92
       System.Web.UI.WebControls.ParameterCollection.GetValues(HttpContext context, Control control) +282
       System.Web.UI.WebControls.SqlDataSourceView.InitializeParameters(DbCommand command, ParameterCollection parameters, IDictionary exclusionList) +344
       System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1251
       System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +84
       System.Web.UI.WebControls.DataBoundControl.PerformSelect() +153
       System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +99
       System.Web.UI.WebControls.GridView.DataBind() +23
       System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +92
       System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +100
       System.Web.UI.Control.EnsureChildControls() +134
       System.Web.UI.Control.PreRenderRecursiveInternal() +109
       System.Web.UI.Control.PreRenderRecursiveInternal() +233
       System.Web.UI.Control.PreRenderRecursiveInternal() +233
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4435


    Author Comment

    Thanks, they both worked.

    Regarding the problem above, I provided a value for the DataTextField but neglected to provide one for the DataNavigateURLField.


    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
    In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now