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

[Solved] Finding Specific Values in a row after an ItemCommand event

1 Answer 265 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Robert LeGood
Top achievements
Rank 1
Robert LeGood asked on 30 Jan 2008, 09:02 PM
I have a Rad Grid with an Button Column on it.   When I click on the button I want to pull specific values from the row that the button is on.

The code I do that with is as follows...

    protected void RadGrid2_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) 
    { 
        if (e.CommandName == "MyCommand") 
        { 
            RadGrid MyGrid = (RadGrid)source; 
            int column = MyGrid.Columns.FindByDataField("ID").OrderIndex 
            string MyID = e.Item.Cells[column].Text; 
            //DO STUFF 
        } 
    } 

Here's the issue:  If I don't touch the table, everything works fine.   If I drag a column up to the top bar to group, or move columns around, the "column" number remains the same, but e.Item.Cells is using the new format of the table, and, if I use "column" as my indexer, I'm getting something random.  (Usually nbsp;)

Could someone demonstrate how to do what I want to do?

Thanks!!


1 Answer, 1 is accepted

Sort by
0
Ves
Telerik team
answered on 31 Jan 2008, 11:46 AM
Hello Robert,

You can find the cell through the column UniqueName like this:

((GridDataItem)e.Item)["ColumnUniqueName"]

You can find more details in this help topic.


Kind regards,
Ves
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Grid
Asked by
Robert LeGood
Top achievements
Rank 1
Answers by
Ves
Telerik team
Share this question
or