Link to home
Create AccountLog in
Avatar of Mariyam
Mariyam

asked on

Input String Was Not In Correct Format VS.Net 2.0

Hi,

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):
   
                                          Results.aspx?KBID={0}

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#.

TIA
-Mari
ASKER CERTIFIED SOLUTION
Avatar of Raju Srivatsavaye
Raju Srivatsavaye
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Avatar of Mariyam
Mariyam

ASKER

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:
              http://localhost:3799/ITKnowledgeBase/Results.aspx?KBID=1
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

Thanks.
Avatar of Mariyam

ASKER

Thanks, they both worked.

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