Solved

Object datasource and Querystring roblem

Posted on 2006-07-09
6
633 Views
Last Modified: 2008-02-01
Hello experts,

I am having trouble assigning a querystring value to a business object parameter.when I do the following;-

<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetGalleryImagesByID"
                TypeName="FixedAuctions.AuctionsDB">
                <SelectParameters>
                    <asp:QueryStringParameter DefaultValue="-1" Name="GalleryID" QueryStringField="GALLERYID"
                        Type="Int32" />
                </SelectParameters>
            </asp:ObjectDataSource>
I get error;-



Input string was not in a correct format.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.FormatException: Input string was not in a correct format.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace:


[FormatException: Input string was not in a correct format.]
   System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +2753603
   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) +264
   System.Web.UI.WebControls.Parameter.get_ParameterValue() +66
   System.Web.UI.WebControls.ParameterCollection.GetValues(HttpContext context, Control control) +254
   System.Web.UI.WebControls.ObjectDataSourceView
 


I f I change the follwoing line;-

<asp:QueryStringParameter DefaultValue="-1" Name="GalleryID" QueryStringField="GALLERYID"
                        Type="Int32" />


to-
<asp:QueryStringParameter DefaultValue="1" Name="GalleryID"
                        Type="Int32" />

everything works fine.

I am using the code in a popup that is called in a javascript function like so;-

HyperLink HyperLink1 = (HyperLink)DataList1.Items[i].FindControl("HyperLink1");
                HyperLink1.Attributes.Add("onclick", "window.open('popup.aspx?IMAGEID=IMAGEID',null,'height=550, width=650,status= no, resizable= no, scrollbars=no, toolbar=no,location=no,menubar=no ');");

I can't seem to find what am missing
0
Comment
Question by:claracruz
  • 3
  • 2
6 Comments
 
LVL 27

Expert Comment

by:Sammy
ID: 17071406
without looking deeper into your code, you have
<asp:QueryStringParameter DefaultValue="-1" Name="GalleryID" QueryStringField="GALLERYID" Type="Int32" />
and your link doesnt have a querystring GALLERYID, instead it has a Querystring IMAGEID

0
 
LVL 4

Author Comment

by:claracruz
ID: 17075176
Hi there,

I had to change this;-


HyperLink1.Attributes.Add("onclick", "window.open('popup.aspx?IMAGEID=IMAGEID',null,'height=550, width=650,status= no, resizable= no, scrollbars=no, toolbar=no,location=no,menubar=no ');");
to

 HyperLink1.Attributes.Add("onclick", "window.open('popup.aspx?IMAGEID="+IMAGEID+",null,'height=550, width=650,status= no, resizable= no, scrollbars=no,

IE.
IMAGEID=IMAGEID'

to

IMAGEID="+IMAGEID+",
0
 
LVL 27

Expert Comment

by:Sammy
ID: 17078318
Did it work after the change or got the same error?

0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 4

Author Comment

by:claracruz
ID: 17088099
problem solved with above change
0
 
LVL 27

Expert Comment

by:Sammy
ID: 17088150
Great, close the question please.
0
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
ID: 17259871
Closed, 250 points refunded.
Netminder
Site Admin
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

708 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

15 Experts available now in Live!

Get 1:1 Help Now