This is a migrated thread and some comments may be shown as answers.

Item command fired

1 Answer 92 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Karen
Top achievements
Rank 1
Karen asked on 03 May 2010, 05:29 AM
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"
                <ItemTemplate> 
                    <div class="ListBoxItem"
                        <table width="130"
                            <tr> 
                                <td> 
                                    <asp:Label ID="lblCity" runat="server"></asp:Label> 
                                    <br /> 
                                    <asp:Label ID="lblAddress"  runat="server"></asp:Label> 
                                </td> 
                                <td align="right" width="15"
                                    <asp:ImageButton ID="btnDelete" CommandName="Delete" ImageUrl="~/Images/icons/delete.png" runat="server" /> 
                                </td> 
                            </tr> 
                        </table> 
                    </div> 
                </ItemTemplate> 
</telerik:RadListBox> 


1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 03 May 2010, 08:36 AM
Hi Karen,

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

C#:
 
    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 
    } 

Regards,
Princy.
Tags
ListBox
Asked by
Karen
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or