I have a repeater which structured like this
<asp:Repeater ID="RpAccBind" runat="server" OnItemDataBound="RpAccBind_ItemDataBound">
<ItemTemplate>
<tr id="acsryRow" runat="server">
<td data-th="Product">
<div class="prodImgMain">
<img src="../instrumentimages/<%# Eval("ProductImage") %>" alt="<%# Eval("ProductName")%>" />
</div>
</td>
<td data-th="Description">
<div class="prodDescriptionContainer">
<ul>
<li>
<span class="prdRow"><%# Eval("ProductName") %></span>
</li>
</ul>
</div>
<div class="quantityIconWrap form-group">
<span class="number-wrapper">
<asp:TextBox Text='<%# Eval("Quantity") %>' ID="txtqty" CssClass="form-control" runat="server" size="3" Width="50" onkeyup="this.value=this.value.replace(/[^0-9]/g,'');" OnTextChanged="txtQtyTextChanged" AutoPostBack="true"></asp:TextBox>
</span>
<span>
<asp:ImageButton ID="lnkAscRemove" runat="server" class="btn" OnClick="lnkRemoveClick" CommandArgument='<%# Eval("ProductId")%>' ImageUrl="../images/deleteIcon.png"></asp:ImageButton>
</span>
</div>
</td>
<td data-th="Amount" style="padding-right: 5%;">
<div class="amountColMain">
<ul>
<li><span><strong><span id="litConPrice" runat="server">$<%# Eval("ConsumerPrice") %></span></strong></span></li>
</ul>
</div>
</td>
<td></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:Repeater>
Now, whenever the txtQty is 0, i want to have the productid in respect of the imagebutton clicked. Right Now, i am using something like
long productId = Convert.ToInt64(((ImageButton)((RepeaterItem)txtQty.Parent).FindControl("lnkAscRemove")).CommandArgument);
It is giving me an error of unable to cast HtmlTableCell to RepeaterItem
Any Kind of help will be appreciated. Thanks in advance
To use
CommandNameandCommandArgument, you need to use aCommandevent, not aClick.Code behind
Update
If you want to get the
ProductIdfrom a TextBox, you could add it as a custom property and then read it in code behind.Code behind