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

Fire an event on row selected Grid

2 Answers 231 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 28 Sep 2011, 08:19 PM
Hi,

I am wondering is there possible to know when a row in a Grid has been selected. The grid doesn't seem to have a server-side event for that and I tried onRowSelected (in the the clientSettings), but it seem that the event is call before the row is selected (in fact, this event call a js function that simply call RadAjaxManager1.ajaxRequest. In the ajaxRequest, I get the selectedItem with the method SelectedItems of my grid, but this method return the old selected item). May anyone help please ?

Thank you  

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 29 Sep 2011, 05:06 AM
Hello  David,

You can attach SelectedIndexChanged event which fires on server selection from Select/Deselect. Another approach is to attach ItemCommand and Check for the Command name.

C#:
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
   {
       if (e.CommandName == RadGrid.SelectCommandName)
       {
       }
   }
protected void RadGrid1_SelectedIndexChanged(object sender, EventArgs e)
   {
 
   }

Thanks,
Shinu.
0
David
Top achievements
Rank 1
answered on 29 Sep 2011, 09:06 PM
Hi Shinu,

Thanks for your fast answer, but I'm not sure to understand it. The first alternative doesn't seem to work. In fact, this event seem to be fired only when I modify the data of the row that is currently selected and not when I just selected this row. For your second alternative, I don't know what you mean by "attach ItemCommand". I try the event, but once again, it is not fired when I select a row. Does I have something else to do to make it work ?

Thank you,
David
Tags
Grid
Asked by
David
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
David
Top achievements
Rank 1
Share this question
or