Input String Was Not In Correct Format VS.Net 2.0


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

Who is Participating?
Raju SrivatsavayeSoftware EngineerCommented:
try this:

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

which one you choose is pretty much up to personal preference.
MariyamAuthor Commented:
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

MariyamAuthor Commented:
Thanks, they both worked.

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

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.