private void myGrid_CommandCellClick(object sender, EventArgs e) |
{ |
GridCommandCellElement gCommand = (sender as GridCommandCellElement); |
if( gCommand.ColumnIndex == 11 ) |
// code.. |
} |
Simple question - I have two command buttons and wondered if it's possible to get the unique name from within the event?! can only find the column index number. gCommand.Name returns ""
Cheers
Ewart.
6 Answers, 1 is accepted
0
Hi ewart,
Thank you for your question. Here is the code you need to use:
Do not hesitate to write me back if you have further questions.
All the best,
Nick
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Thank you for your question. Here is the code you need to use:
MessageBox.Show(gCommand.Value.ToString()); |
Do not hesitate to write me back if you have further questions.
All the best,
Nick
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
ewart
Top achievements
Rank 1
answered on 21 Nov 2008, 06:45 AM
Sorry, thats the value; I wondered if it's possible to get the unique name from within the event?
cheers
ewart
cheers
ewart
0
Hi ewart,
Thank you for your questions.
If you need just row number you can use gCommand.RowIndex.
You may use another cell on the same row to distinguish between click on one row or another:
The code above accesses the cell value in the 6th cell on the same row.
Do not hesitate to write me back if you have more questions.
All the best,
Nick
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Thank you for your questions.
If you need just row number you can use gCommand.RowIndex.
You may use another cell on the same row to distinguish between click on one row or another:
this.radGridView1.Rows[gCommand.RowIndex].Cells[5].Value |
The code above accesses the cell value in the 6th cell on the same row.
Do not hesitate to write me back if you have more questions.
All the best,
Nick
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
ewart
Top achievements
Rank 1
answered on 21 Nov 2008, 08:20 PM
Huh? Sorry perhaps my question wasn't clear as we're talking at cross purposes - I shall elaborate. What I want to know is "How to get the command column name" from within the following event:
Why is because ColumnIndex changes everytime someone re-orders the columns. Ideally I'd use the command column name, something like e.g.
I feel a bit sheepish about not being able to find the relevant property in the debug window (and there is basically nothing on "reorder" in the documentation) - but I know it must be there somewhere otherwise you'd have no way of handling re-ordered columns, I just can't figure it out!
cheers
ewart
private void myGrid_CommandCellClick(object sender, EventArgs e) |
{ |
GridCommandCellElement gCommand = (sender as GridCommandCellElement); |
if( gCommand.ColumnIndex == 11 ) |
// code.. |
} |
Why is because ColumnIndex changes everytime someone re-orders the columns. Ideally I'd use the command column name, something like e.g.
private void myGrid_CommandCellClick(object sender, EventArgs e) |
{ |
GridCommandCellElement gCommand = (sender as GridCommandCellElement); |
if( gCommand.ColumnName == "cmdEdit" ) |
// code.. |
if( gCommand.ColumnName == "cmdDelete" ) // code.. } |
cheers
ewart
0
Hello ewart,
Thank you for contacting me back.
You can use the column header text:
Do not hesitate to contact me back if you have more questions.
Kind regards,
Nick
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Thank you for contacting me back.
You can use the column header text:
gCommand.ColumnInfo.HeaderText |
Do not hesitate to contact me back if you have more questions.
Kind regards,
Nick
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Support@silverbear.com
Top achievements
Rank 1
answered on 03 Dec 2014, 03:48 PM
- He was actually after:gCommand.ColumnInfo.Name