Delete item based on command name

2 posts, 0 answers
  1. L
    L avatar
    298 posts
    Member since:
    Apr 2008

    Posted 22 Aug 2014 Link to this post


    How do I remove or delete item from listbox using command name? Thanks a lot

    Here is my code:

    <telerik:RadListBox ID="lbProductList" runat="server" Width="100%"  EnableViewState="true" ViewStateMode="Enabled" Skin="Metro" style="top: 0px; left: 0px" AutoPostBack="True" EnableDragAndDrop="True">
                                        <td class="leftbox"><asp:Image ID="Image1" CssClass="circularsmall" runat="server" EnableViewState="true" ImageUrl='<%# "~/images.ashx?id=" + Eval("PhotoThumb")%>' /></td>
                                        <td class="rightbox"><div class="semibold"  style="word-wrap:break-word"><%# Eval("ProductName")%></div>
                                        <asp:LinkButton ID="lnkDelete" CommandName="remove" Text="Remove" style="text-decoration:none;color:darkgray;font-size:smaller" runat="server"></asp:LinkButton></div>
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 25 Aug 2014 in reply to L Link to this post


    I guess you want to delete the selected item on click of 'Remove' button. Try to attach the onClick event for the LinkButton and do the following C# code snippet which works fine at my end.

    protected void lnkDelete_Click(object sender, EventArgs e)
        RadListBoxItem item = (RadListBoxItem)lbProductList.SelectedItem;

    Please elaborate your requirement if it doesn't help.
Back to Top