asp.nettelerikitemtemplateradlistbox

How to Recognize the CommandName of a LinkButton Inside an ItemTemplate af a RadListBox


I added an itemtemplate to my radlistbox and also added one label and two linkbutton(s) in it ...
my radlistbox is like below :

<telerik:RadListBox ID="RadlbOfImageGroup" runat="server" DataKeyField="ID" DataSortField="Title"
    DataSourceID="sdsImagesGroup" DataTextField="Title" DataValueField="ID" Skin="BlackByMe"
    EnableEmbeddedSkins="False" Width="260px" Height="365px" EmptyMessage="no rec!"
    AutoPostBack="True" OnSelectedIndexChanged="RadlbOfImageGroup_SelectedIndexChanged"
    CausesValidation="False">
    <ItemTemplate>
        <table style="width: 100%;">
            <tr style="width: 100%;">
                <td style="width: 64%;">
                    <asp:Label ID="lblTitleOfIG" runat="server" CssClass="lbl_ListBox_IG_Title" Text='<%# Eval("Title") %>'></asp:Label>
                </td>
                <td style="width: 18%; text-align: center;">
                    <asp:LinkButton ID="lbEditIG" runat="server" CausesValidation="False" CommandName="Edit"
                        CssClass="lb_ListBox_IG" OnClick="lbEditIG_Click">Edit</asp:LinkButton>
                </td>
                <td style="width: 18%; text-align: center;">
                    <asp:LinkButton ID="lbDeleteIG" runat="server" CausesValidation="False" CommandName="Delete"
                        CssClass="lb_ListBox_IG" OnClick="lbDeleteIG_Click">Delete</asp:LinkButton>
                </td>
            </tr>
        </table>
    </ItemTemplate>
</telerik:RadListBox>

My Problem is how can I check the CommandName of LinkButtons in code above when I click on them? (We don't have access to these LinkButtons in CodeBehind)

I know we do not need CommandName for those LinkButtons / I Just want to know is it possible to read them from codebehind?


Solution

  • here is the code that has been introduced by telerik team :

    protected void lbDeleteIG_Click(object sender, EventArgs e)
       {
           LinkButton btn = sender as LinkButton;
           if (btn.CommandName=="Delete")
           {
               Response.Write("Deleted");
           }
       }