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
MariyamAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Raju SrivatsavayeSoftware EngineerCommented:
try this:

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
craskinCommented:
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:
              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.
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.




It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.