Problem accessing HtmlInputHidden
-
I'm trying to access the value of a HtmlInputHidden inside a datalist, but I get "Object reference not set to an instance of an object" as an error when I try to call the value. Here is my code: Protected Sub DataList1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles DataList1.ItemDataBound Select Case e.Item.ItemType Case ListItemType.Item, ListItemType.AlternatingItem 'Dim row As DataRowView = CType(e.Item.DataItem, DataRowView) Dim TitleLink As HyperLink = CType(e.Item.FindControl("ProdTitleLink"), HyperLink) Dim TextLink As HyperLink = CType(e.Item.FindControl("ProdTextLink"), HyperLink) Dim prodID As HtmlInputHidden = CType(e.Item.FindControl("ProductID"), HtmlInputHidden) TextLink.NavigateUrl = "productDetails.aspx?catID=" & Request.QueryString("catID") & "Id" & prodID.Value TitleLink.NavigateUrl = "productDetails.aspx?catID=" & Request.QueryString("catID") & "Id" & prodID.Value End Select End Sub Code of Datalist:
Product
Qty
Price