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

[Solved] Cell value

1 Answer 86 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bill
Top achievements
Rank 1
Bill asked on 02 Mar 2010, 07:18 PM
I'm using RadGrid Ajax Q3 2009.  I can't believe I'm having trouble with something so simple.  All I want to do is retrieve a value of a non-editable cell for a row in edit mode. 

Using the Update or Item Command event to get the value

GridDataItem

 

dataitem = e.Item as GridDataItem;

 

string mycell = dataitem["MyColumn"].Text;

always gives mycell with a value of  " "

What the hey am I doing wrong??

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 03 Mar 2010, 05:29 AM
Hello Bill,

Just add "MyColumn" to the DataKeyNames collection of the MasterTableView and in the ItemCommand event get the column's value as follows:

C#:
 
    protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
    { 
          // Check for the CommandName 
          // If the item in EditMode, then typecast to GridEditFormItem/GridEditableItem 
          string col1Value = ((GridDataItem)e.Item).GetDataKeyValue("MyColumn").ToString(); 
        } 
    } 

-Shinu.
Tags
Grid
Asked by
Bill
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or