I'm trying to set the visibility of imgArrow when an item in my datalist dlProd is clicked on.
Here is my image:
Here's the code behind:
I keep getting the error: Object ref not set to instance of an object...
Any ideas?
Here is my image:
Code:
<asp:datalist id="dlCategories" runat="server">
<ItemTemplate>
<P class="wht_14" style="MARGIN: 8px 18px 2px 0px" align="right"><b>
<asp:LinkButton id="Linkbutton1" Runat="server" CommandArgument='<%# Container.DataItem("categoryID") %>' CommandName="Edit">
<%#Container.DataItem("CategoryName")%>
</asp:LinkButton></b>
</P>
<!-- Begin Product Listing -->
<asp:Panel id="PanelProd" runat="server" Visible="false">
<asp:DataList ID="dlProd" Runat="server">
<ItemTemplate>
<P class="wht_11" style="MARGIN: 0px 26px 4px 0px" align="right">
<asp:Image ID="imgArrow" Runat="server" Visible="False" ImageUrl="/images/ico_arrowRight.gif"></asp:Image>
<asp:LinkButton id="linkButton2" Runat="server" OnClick="ProductDetailClicked" CommandArgument='<%# Container.DataItem("productsID") %>'>
<%#Container.DataItem("ProductName")%>
</asp:LinkButton></P>
</ItemTemplate>
</asp:DataList>
</asp:Panel>
<!-- End Product Listing -->
</ItemTemplate>
</asp:datalist>
Here's the code behind:
Code:
Public Sub ProductDetailClicked(ByVal sender As Object, ByVal e As EventArgs)
PanelMainProducts.Visible = False
PanelProduct.Visible = True
myConnection = New SqlConnection(conString)
myConnection.Open()
mycommand = New SqlCommand("getSpecificProduct", myConnection)
mycommand.CommandType = CommandType.StoredProcedure
Dim objButton As LinkButton
If Session("ProdID") = "" Then
objButton = CType(sender, LinkButton)
mycommand.Parameters.Add(New SqlParameter("@productsID", SqlDbType.Int))
mycommand.Parameters("@productsID").Value = objButton.CommandArgument
Else
mycommand.Parameters.Add(New SqlParameter("@productsID", SqlDbType.Int))
mycommand.Parameters("@productsID").Value = sender
End If
myReader = mycommand.ExecuteReader
Me.Bind_Data(myReader)
myConnection.Close()
imgArrow = CType(Me.dlCategories.FindControl("imgArrow"), System.Web.UI.WebControls.Image)
imgArrow.Visible = True
End Sub
I keep getting the error: Object ref not set to instance of an object...
Any ideas?