Solved

Object datasource and Querystring roblem

Posted on 2006-07-09
6
638 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
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…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

920 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

13 Experts available now in Live!

Get 1:1 Help Now