C# Pass textbox content via CommandArgument in Repeater

ComfortablyNumb picture ComfortablyNumb · Jun 20, 2011 · Viewed 12.7k times · Source
<asp:Repeater ID="Cartridges" runat="server" onitemcommand="Cartridges_ItemCommand">
    <ItemTemplate>
        <p class="cartprice"><%#String.Format("{0:C}", Eval("Price"))%></p>
        <hr class="hr4" /> 
        <p class="cartqty">QTY <asp:TextBox ID="cartQty" Text="0" runat="server"></asp:TextBox> </p>
        <div class="cartbuy2"><asp:LinkButton ID="buy" runat="server" CommandName="AddtoCart" CommandArgument=<%#Eval("cartID") %> Text="Buy"></asp:LinkButton></div>
   </ItemTemplate>
</asp:Repeater>

How can I pass the textbox value within CommandArgument? Sorry totally lost...

Answer

Mohammed Swillam picture Mohammed Swillam · Jun 20, 2011

Did you try: CommandArgument='<%#Eval("cartID") %>'

this is different from yours as it is surrounded by a single quote, I guess this is the correct syntax.