Delete item from ListBox

2 posts, 0 answers
  1. Meghna
    Meghna avatar
    37 posts
    Member since:
    Jun 2008

    Posted 15 Mar 2010 Link to this post

    I have following code snippet used for deleteing an selected item from ListBox. Following is the aspx code

    <

     

    telerik:RadListBox ID="rlbTag" runat="server" AutoPostBack="false" OnClientItemDoubleClicked="DeleteTags()" Width="250" EnableEmbeddedSkins="true" Height="80px" AllowAutomaticUpdates="true">

     

     

    <ItemTemplate>

     

     

    <table width="100%">

     

     

    <tr>

     

     

    <td align="left" ><asp:Label ID="lblTags" Text='<%# DataBinder.Eval(Container, "Text") %>' runat="server"></asp:Label></td>

     

     

    <td align="right"><asp:ImageButton ImageUrl="~/images/Delete.gif" ID="btnDelete" Text="Delete" OnClientClick="return removeItem(event)" runat="server"/></td>

     

    <%

    --<asp:CheckBox id="cbUsers" runat="server" OnClick="checkboxReportClick(event);" Text='<%# DataBinder.Eval(Container, "Text") %>' />--%>

     

     

    </tr>

     

     

    </table>

     

     

    </ItemTemplate>

     

     

    </telerik:RadListBox>

     

     

    </td>

    Following is the implementation of removeItem method which will be triggered when user click on delete button in List Box item template

     

    function

     

    removeItem(e)

     

    {

     

     

    var RdListBox=$find("<%= rlbTag.ClientID %>");

     

     

     

    var item = RdListBox.get_selectedItem();

     

    RdListBox._selectedIndex = 0;

     

    RdListBox.trackChanges();

    RdListBox.get_items().remove(item);

    RdListBox.commitChanges();

    }

    When  first time user clicks delete button to remove an item, selected item is gettiung null. Seconmd time it gets deleted from the list.
    Can anyone help me to acheive remove functionality on cleint side?

  2. Cliff
    Cliff  avatar
    1 posts
    Member since:
    May 2012

    Posted 06 Jun 2014 in reply to Meghna Link to this post

    you need something like this: http://www.telerik.com/forums/remove-element-of-a-double-click-radlistbox
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top