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

How to select a row and call a method (server-side) ?

1 Answer 215 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Suzi
Top achievements
Rank 1
Suzi asked on 11 Sep 2008, 09:44 AM
Hi,

I am using the RadGrid. I need to select a row (not only the text of the row) and call a method (server-side). I don't know how to do it.

I konw how to call a method (client-side) : 

protected void RadGridFlashLines_ItemCreated(object sender, GridItemEventArgs e){
if (e.Item.DataItem != null){
if (e.Item is GridDataItem){

e.Item.Attributes[

"href"] = "#";

e.Item.Attributes[

"onclick"] = String.Format("return ShowEditForm('{0}','{1}');", ((Flash)e.Item.DataItem).Fla_Id, e.Item.ItemIndex);
}} }

I would like instead, to call, for example, a method name DisplayElementSelected() (server-side). Is it possible with the RadGrid component ?

Thank you in advance,

1 Answer, 1 is accepted

Sort by
0
Accepted
Veli
Telerik team
answered on 14 Sep 2008, 08:11 PM
Hi Suzi,

This requirement is easily implemented in RadGrid, but it requires a totally different approach. If you need to always call a server-side method on row select, here are the steps you need to take:

1. Allow row select:

RadGrid1.ClientSettings.Selecting.AllowRowSelect = true;

2. Enable postback on row click:

RadGrid1.ClientSettings.EnablePostBackOnRowClick = true;

Attach to the server-side ItemCommand event of your RadGrid and check for the "RowClick" command name. Your custom method call goes there:

void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
    if (e.CommandName == "RowClick"
    { 
        //your custom method call here 
    } 


Greetings,
Veli
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Suzi
Top achievements
Rank 1
Answers by
Veli
Telerik team
Share this question
or