Item command fired

2 posts, 0 answers
  1. Karen
    Karen avatar
    27 posts
    Member since:
    Jul 2008

    Posted 03 May 2010 Link to this post

    Hello I have a RadListBox with ItemTemplates which have image button inside, how can I pick the event when the button is clicked as I see RadListBox has no OnItemCommand event.
    In my case I put custom delete button inside ItemTemplate like this
    <telerik:RadListBox ID="listboxAddresses" Height="158" Width="200" runat="server"
                        <div class="ListBoxItem"
                            <table width="130"
                                        <asp:Label ID="lblCity" runat="server"></asp:Label> 
                                        <br /> 
                                        <asp:Label ID="lblAddress"  runat="server"></asp:Label> 
                                    <td align="right" width="15"
                                        <asp:ImageButton ID="btnDelete" CommandName="Delete" ImageUrl="~/Images/icons/delete.png" runat="server" /> 

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 03 May 2010 Link to this post

    Hi Karen,

    You could attach OnClick event for the ImageButton and get access to corresponding RadListBoxItem by using NamingContainer property of the button.

        protected void btnDelete_Click(object sender, ImageClickEventArgs e) 
            ImageButton img = (ImageButton) sender; 
            RadListBoxItem item = (RadListBoxItem)img.NamingContainer; 
            // Your code to delete the item goes here 

Back to Top