Solved

Object datasource and Querystring roblem

Posted on 2006-07-09
6
644 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

816 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

12 Experts available now in Live!

Get 1:1 Help Now