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

Value for GridViewCommandColumn

3 Answers 410 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Bob
Top achievements
Rank 1
Bob asked on 14 May 2008, 08:25 PM
I've bound my RadGrid to a data reader, and added a GridViewCommandColumn.  How do I set the value of this button, so that when I catch the _OnClick_ event, I'll know a unique id for that row (and not the row # or column #)?

I've tried setting:
.FieldName = "db_field_with_value"

Thanks!

3 Answers, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 17 May 2008, 04:32 PM
Hi Bob,

Thank you for this question.

When processing the CommandCellClick event, the sender argument contains the GridCommandCellElement that caused the event. You can access the other cells values through the RowInfo property of the cell.

Consider the following code snippet:

void radGridView1_CommandCellClick(object sender, EventArgs e) 
    GridCommandCellElement cell = (GridCommandCellElement)sender; 
    int value = (int)cell.RowInfo.Cells["ID"].Value; 
 
I hope this helps. Let me know, if you need further assistance.

 
Kind regards,
Jack
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Idan Varshavski
Top achievements
Rank 1
answered on 04 Jan 2010, 09:39 AM
hi
when using the same event how do I get the unique name of the column?
I have several command columns and because i have only one event to register to i need to know which button was pressed in order to perform the correct command.

thanks,
Idan
0
Nikolay
Telerik team
answered on 04 Jan 2010, 01:19 PM
Hello Idan Varshavski,

You can get the UniqueName of a column by casting the column to GridViewDataColumn:
void radGridView1_CommandCellClick(object sender, EventArgs e)
{
    string uniqueName = ((GridViewDataColumn)this.radGridView1.CurrentColumn).UniqueName;
}

If you have additional questions, feel free to contact me.

Kind regards,
Nikolay
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
Bob
Top achievements
Rank 1
Answers by
Jack
Telerik team
Idan Varshavski
Top achievements
Rank 1
Nikolay
Telerik team
Share this question
or