[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Input String Was Not In Correct Format VS.Net 2.0

Posted on 2006-03-23
4
Medium Priority
?
1,898 Views
Last Modified: 2011-10-03
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
0
Comment
Question by:Mariyam
  • 2
4 Comments
 
LVL 9

Accepted Solution

by:
Raju Srivatsavaye earned 1000 total points
ID: 16274084
try this:

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

Assisted Solution

by:craskin
craskin earned 400 total points
ID: 16274130
you can also do NavigateUrl='<%# "Results.aspx?KBID=" & Container.DataItem("KBID") %>'

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

Author Comment

by:Mariyam
ID: 16283745
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.
0
 

Author Comment

by:Mariyam
ID: 16315943
Thanks, they both worked.

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




0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Loops Section Overview
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month20 days, 14 hours left to enroll

864 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