SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have created a Sharepoint WebPart, and I have given it a custom ToolPart that includes a Grid (a Telerik RadGrid, to be exact, though that is rather irrelevant). I have populated the grid, and created a GridButtonColumn object to add to the grid:

protected override void CreateChildControls()
            GridButtonColumn c = new GridButtonColumn();
            c.ConfirmText = "Really Delete?";
            c.ConfirmDialogType = GridConfirmDialogType.RadWindow;
            c.ConfirmTitle = "Delete";
            c.ButtonType = GridButtonColumnType.LinkButton;
            c.Text = "Delete";
            c.UniqueName = "DeleteColumn";
    // ...

    grid.DeleteCommand += new GridCommandEventHandler(Grid_DeleteCommand);

The grid renders correctly - populated with data and with the delete button present.

Now, when I click any of the delete button, the Grid_DeleteCommand() event does not get triggered. However, when I add a random button outside of the grid, it's click event gets triggered:

Button b = new Button();
    b.Text = "Hello World";
    b.Click += new EventHandler(Button_Click);

I'm not able to debug on this installation of Sharepoint (or maybe I can, but attaching to the process hasn't allowed me to do so yet), so the method of both of those events is simply a redirection to Google. That is how I check to see if the events fire:

    string AbsoluteUri ="";

The only difference I can see between the two is that, with the 'Delete' button, it is nested inside of a Grid control, whereas with the 'Hello World' button, there is no nesting.

How would I be able to have the Grid_DeleteCommand fire when I click the button in the grid?

share|improve this question
You say that the fact that you are using a Telerik grid control is irrelevant, but it seems that the problem arises with controls rendered inside the Telerik control. Are you sure this is a general SharePoint question? If it is Telerik related then you should ask it on the Telerik support forum as it would be off-topic here. Thanks. – SPDoctor Feb 8 '12 at 17:57
I'm open to the possibility. However, I have the same issue as described above when using controls. Further, when I do the above in a standard webforms app, it works. – splatto Feb 8 '12 at 18:09
Okay, we'll take your word for it. – SPDoctor Feb 8 '12 at 21:51

The answer is - I was missing a single line of code to set a property of the column:

c.CommandName = "Delete";
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.