D
Darren Smith
Hi There,
I have a shopping cart app that displays products along with a textbox
(to enter quantity) and an image button to add the item to the
shopping cart. Please explain why my below Button_Click procedure
does not retrieve the value of the textbox where the button was
clicked.
Thanks in Advance,
Darren
Sub Button_Click(s as Object, e as ImageClickEventArgs)
Dim Btn As System.Web.UI.WebControls.ImageButton = s
Dim iId as integer
iId=Btn.CommandArgument
Response.write (iId)
Dim tb as System.Web.UI.WebControls.TextBox =
btn.Parent.FindControl("txtValue")
Response.write ("TextBox Value=" & tb.Text)
End Sub
-------------------------------------------------------
<form id="frmProducts" runat="server">
<asp:repeater id="rptProducts" Runat="server">
<ItemTemplate>
a href="ProductInfo.aspx?id=<%# DataBinder.Eval(Container.DataItem,
"prodid") %>"><%# DataBinder.Eval(Container.DataItem, "prodname")
%></a></b></td>
<%# DataBinder.Eval(Container.DataItem, "catdesc") %></td>
<%# formatcurrency(DataBinder.Eval(Container.DataItem,
"retailprice"),2) %>
member price: <b><%#
formatcurrency(DataBinder.Eval(Container.DataItem, "memberprice"),2)
%></b></td>
<asp:TextBox runat="server" width="20" name="txtValue" id="txtValue"
CommandArgument=<%# DataBinder.Eval(Container.DataItem, "prodid") %>
/>
<asp:imagebutton id=btnAddCart CommandArgument=<%#
DataBinder.Eval(Container.DataItem, "prodid") %> BorderWidth="0"
onclick=Button_Click Runat="server" ImageUrl="Frame/btnAdd.gif"/>
</ItemTemplate>
</asp:repeater>
I have a shopping cart app that displays products along with a textbox
(to enter quantity) and an image button to add the item to the
shopping cart. Please explain why my below Button_Click procedure
does not retrieve the value of the textbox where the button was
clicked.
Thanks in Advance,
Darren
Sub Button_Click(s as Object, e as ImageClickEventArgs)
Dim Btn As System.Web.UI.WebControls.ImageButton = s
Dim iId as integer
iId=Btn.CommandArgument
Response.write (iId)
Dim tb as System.Web.UI.WebControls.TextBox =
btn.Parent.FindControl("txtValue")
Response.write ("TextBox Value=" & tb.Text)
End Sub
-------------------------------------------------------
<form id="frmProducts" runat="server">
<asp:repeater id="rptProducts" Runat="server">
<ItemTemplate>
a href="ProductInfo.aspx?id=<%# DataBinder.Eval(Container.DataItem,
"prodid") %>"><%# DataBinder.Eval(Container.DataItem, "prodname")
%></a></b></td>
<%# DataBinder.Eval(Container.DataItem, "catdesc") %></td>
<%# formatcurrency(DataBinder.Eval(Container.DataItem,
"retailprice"),2) %>
member price: <b><%#
formatcurrency(DataBinder.Eval(Container.DataItem, "memberprice"),2)
%></b></td>
<asp:TextBox runat="server" width="20" name="txtValue" id="txtValue"
CommandArgument=<%# DataBinder.Eval(Container.DataItem, "prodid") %>
/>
<asp:imagebutton id=btnAddCart CommandArgument=<%#
DataBinder.Eval(Container.DataItem, "prodid") %> BorderWidth="0"
onclick=Button_Click Runat="server" ImageUrl="Frame/btnAdd.gif"/>
</ItemTemplate>
</asp:repeater>