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

ItemCommand Event Not Firing

1 Answer 82 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Antony
Top achievements
Rank 1
Antony asked on 13 Oct 2008, 07:53 PM
Hi,

We are supporting 2 modes for a user to display the edit usercontrol,
firstly
 
<telerik:GridButtonColumn CommandName ="Edit" ButtonType="LinkButton" DataTextField="Title" HeaderText="Title" SortExpression="Title" UniqueName="Title"></telerik:GridButtonColumn>

and secondly by selecting the row via a checkbox 

<

 

telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" HeaderText="Select"></telerik:GridClientSelectColumn>

 

and clicking on a toolbar "Properties" button.

When clicking on the linkbutton column the ItemCommand fires but the following code in the toolbar button event does not cause the ItemCommand event to fire.

 

if (this.grid.SelectedIndexes.Count == 1)

 

{

 

string index = this.grid.SelectedIndexes[0];

 

 

this.grid.MasterTableView.Items[index].Edit = true;

 

 

this.grid.Rebind();

 

 

this.grid.MasterTableView.Items[index].Selected = true;

 

}

Basically the grid is bound to a readonly business object, the intention is to retrieve the ID value of the user selected row in the ItemCommand event and load a Read/Write business object which will be used to populated the controls in the usercontrol displayed by the grid during edit mode.

Any idea how I can achieve this?

Many thanks
Antony

1 Answer, 1 is accepted

Sort by
0
Antony
Top achievements
Rank 1
answered on 14 Oct 2008, 07:48 AM
I found the answer I was looking for in another post.

Instead of using the following in my custom Toolbar click event:

this.Grid.MasterTableView.Items[index].Edit = true;

 

To place the selected row into edit mode, use the following

this.Grid.MasterTableView.Items[index].FireCommandEvent("Edit",String.Empty);

this ensures that the ItemCommand event fires and hence solves my problem.

Hopefully someone finds this helpful

Antony

Tags
Grid
Asked by
Antony
Top achievements
Rank 1
Answers by
Antony
Top achievements
Rank 1
Share this question
or