•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 425,766 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,395 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 880 | Replies: 4
![]() |
•
•
Join Date: Dec 2004
Posts: 37
Reputation:
Rep Power: 4
Solved Threads: 0
I'm using ASP.NET and VB 2005. I'm trying to get a QueryString passed in the URL into a UserControl and I need to pass it as an integer because that is how it will be pulled from the database.
Here is part of the .aspx page:
Here is my VB Code Behind file:
Basically I'm pulling invID from the URL and I need inventoryID in uc1 to be the value of invID as an integer.
If I put inventoryID="3" in the uc1, then it works fine. No matter how I try to set inventoryID equal to the int value of invID I get a "Input string was not in a correct format" error.
I'm sure its something simple I'm just missing, so any help would be appreciated.
Here is part of the .aspx page:
<%@ register src="frmOrderProductDisplay.ascx" tagname="ProductDisplay" tagprefix="uc1" %>
<div>
<br />
<h3>
Item Details</h3>
<uc1:ProductDisplay ID="ProductDisplay1" runat="server" inventoryID='invID' />
<br />
<asp:Button ID="btnContinue" runat="server" PostBackUrl="~/frmOrder.aspx" Text="Continue Shopping" /><br />
<br />
</div>Here is my VB Code Behind file:
Partial Class frmOrderItemDetail
Inherits System.Web.UI.Page
Dim sInvID As String
Dim invID As Integer
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim sInvID As String = Request.QueryString("invID")
Dim invID As Integer = Int32.Parse(sInvID)
End Sub
End ClassBasically I'm pulling invID from the URL and I need inventoryID in uc1 to be the value of invID as an integer.
If I put inventoryID="3" in the uc1, then it works fine. No matter how I try to set inventoryID equal to the int value of invID I get a "Input string was not in a correct format" error.
I'm sure its something simple I'm just missing, so any help would be appreciated.
•
•
Join Date: Feb 2008
Posts: 51
Reputation:
Rep Power: 1
Solved Threads: 3
If you have a public property in your control name inventoryID, then in the page's code-behind, in the Page_Load event, add the line
If the property is strongly typed, it will only accept an integer. You can remove the following attribute from the instance of your control in the .aspx file.
ProductDisplay1.inventoryID = Request.QueryString("invID")If the property is strongly typed, it will only accept an integer. You can remove the following attribute from the instance of your control in the .aspx file.
inventoryID='invID'
•
•
Join Date: Dec 2004
Posts: 37
Reputation:
Rep Power: 4
Solved Threads: 0
•
•
•
•
If you have a public property in your control name inventoryID, then in the page's code-behind, in the Page_Load event, add the line
ProductDisplay1.inventoryID = Request.QueryString("invID")
If the property is strongly typed, it will only accept an integer. You can remove the following attribute from the instance of your control in the .aspx file.
inventoryID='invID'
![]() |
•
•
•
•
•
•
•
•
DaniWeb ASP.NET Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Other Threads in the ASP.NET Forum
- Previous Thread: UI with XML
- Next Thread: ITs working in virtual directory but not in root website URL


Linear Mode