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

Adding Custom CommandItem

1 Answer 119 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 28 Nov 2011, 08:09 PM
Hello,

I'm having an issue with a custom command item that I have added.  Below is the code used to add this command:
(I need to add this dynamically because not all users will be allowed to delete.)
If (TypeOf e.Item Is GridCommandItem) Then
    Dim btnDelete = New LinkButton()
    btnDelete.ID = "btnDelete"
    btnDelete.Text = "  Delete"
    btnDelete.CommandName = "Delete"
    btnDelete.Attributes("onclick") = "javascript:return confirm('Do you want to delete this item?')"
    Dim cmdItem As GridCommandItem = CType(e.Item, GridCommandItem)
    cmdItem.Controls(0).Controls(0).Controls(0).Controls(0).Controls.Add(btnDelete)
End If

How can I get this control to be handled by the RadGrid_ItemCommand Handler?

Thank you,
Kevin

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 29 Nov 2011, 04:42 AM
Hello Kevin,

You can check for the CommandName as shown below.
C#:
void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
{
 if (e.CommandName == "Delete")
 {//your code
 }
}

-Shinu.
Tags
Grid
Asked by
Kevin
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or