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:
<%@ 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 Class
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.