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

[Solved] getDataKeyValue Question

3 Answers 161 Views
Grid
This is a migrated thread and some comments may be shown as answers.
AereoN
Top achievements
Rank 1
AereoN asked on 19 Nov 2009, 03:58 AM
Instead of grid.getDataKeyValue("ColumnName")
Is there a way for me to retrieve the value using integer, like 0 for the 1st column, 1 for the 2nd column?
My grid data is dynamic, hence the column name is not static.

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 19 Nov 2009, 07:48 AM
Hai AereoN,

You can access the cell values by using following code.

CS:
 
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            string str = item.Cells[2].Text.ToString(); // Get the row value without using column name 
        }              
    } 
[Note: the first two columns will be GridExpandColumn and GridRowIndicator column, so try the index starts from 2]

Regards,
Shinu.
0
AereoN
Top achievements
Rank 1
answered on 19 Nov 2009, 07:51 AM
Hi Shinu,
Thanks for the reply.
However I'm triggering that event on a button click instead of the grid client event.
Is there anyway I can achieve that without the event argument?
0
Princy
Top achievements
Rank 2
answered on 19 Nov 2009, 10:42 AM
Hello,

Try out the following code to access cell values using cell index on a button click:
c#:
 protected void Button1_Click(object sender, EventArgs e) 
    { 
        foreach (GridDataItem dataItem in RadGrid1.Items) 
        { 
            string strtxt = dataItem.Cells[2].Text; 
        } 
    } 

Thanks
Princy.
Tags
Grid
Asked by
AereoN
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
AereoN
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or