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

grid button events

2 Answers 82 Views
Grid
This is a migrated thread and some comments may be shown as answers.
usman
Top achievements
Rank 1
usman asked on 23 Dec 2011, 09:25 AM
in telerik grid I had a template field and included an ASP button in it
I want 2 simple task to be performed from this button 
1)I want to select different values in the Grid by that button click and pass it in session variable Or if possible to select the PK of that tuple.I am using LINQ and binding the grid from code behind.
 2) I wan to conditionally enable and disable button present in template field of RAD Grid 


Thanks 

2 Answers, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 23 Dec 2011, 11:21 AM
The target GridDataItem and owner table is accessible from the Click event of the button in your template. Try the following:

protected void Button_Click(object sender, EventArgs e)
{
    Button btn = (Button)sender;
    GridDataItem gridItem = (GridDataItem)btn.NamingContainer;
    object dataKey = gridItem.GetDataKeyValue("[KEY_FIELD_NAME]");
    //save dataKey somewhere
}

Veli
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
usman
Top achievements
Rank 1
answered on 23 Dec 2011, 11:39 AM
sorry , it doesnt answer my question 
Tags
Grid
Asked by
usman
Top achievements
Rank 1
Answers by
Veli
Telerik team
usman
Top achievements
Rank 1
Share this question
or