hi all, am quite new to asp.net am trying to implement an 'add to cart' button which is generated in a listView
on clicking the imagebutton am trying to add the the product id and quantity=1 to my sortedlist Session
i tried to use command argument but no success
am i doing it right ?
<asp:ListView ID="listview1" GroupItemCount="3" runat="server">
<LayoutTemplate>
<div id="itemListView">
<asp:PlaceHolder runat="server" ID="groupPlaceHolder" />
</div>
</LayoutTemplate>
<GroupTemplate>
<div style="clear: both;">
<asp:PlaceHolder runat="server" ID="itemPlaceHolder" />
</div>
</GroupTemplate>
<ItemTemplate>
<div class="lvProduct">
<div class="productDisplayImage">
<asp:Imagebutton imageURl='<%# Eval("imageUrl") %>'
PostBackUrl= '<%#string.concat("~/productDetail.aspx?pid=",Eval("pid")) %>'
width="175px" Height="160px" runat="server"/>
</div>
<div class="productPriceDisplay">
Price: $<%# Eval("price")%> <asp:ImageButton imageUrl="~/assignment/images/addToCartButton.png" ImageAlign="top"
onCommand="addToCart" commandArgument= '<%#string.concat("Eval("pid")) %>'
Width="100px" height="25px" style="margin-left:10px;" runat="server"/>
</div>
</div>
</ItemTemplate>
<Itemseparatortemplate>
<div class="itemSep">
</div>
</ItemSeparatorTemplate>
<GroupSeparatorTemplate>
<div class="groupSep">
</div>
</GroupSeparatorTemplate>
<EmptyDataTemplate>
</EmptyDataTemplate>
</asp:ListView>
Protected Function addToCart(ByVal sender As Object, ByVal e As CommandEventArgs) As Integer
Dim pid As String = e.CommandArgument.ToString
If Not IsNothing(Session("cart")) Then
Dim slCart As SortedList = CType(Session("cart"), SortedList)
slCart.Add(pid, "1")
Response.Redirect("~/testing.aspx")
Else
Dim slCart As New SortedList
slCart.Add(pid, "1")
Response.Redirect("~/testing.aspx")
End If
Return Nothing
End Function