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

Access to Grid Column's value

1 Answer 73 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Armen
Top achievements
Rank 1
Armen asked on 06 May 2009, 01:46 AM
Hello,

I would like on the postback loop the RadGrid and get the value of particular column like ("Column1") for each rows.
something like 

 

 

 

protected void but1Click(object sender, EventArgs e)

 

{
    foreach (GridItem item in RadGrid1.MasterTableView.Items)

        {

            if (item is GridDataItem)

        {

            GridDataItem eItem = item as GridDataItem;

            string svalue = eItem.GetDataKeyValue("Column1")

        }

    }

}

It seems like "GetDataKeyValue" is not right way to get the value.

 

 

What is the efficient way to get the value of each Column?

Thank you

1 Answer, 1 is accepted

Sort by
0
Todd Anglin
Top achievements
Rank 2
answered on 06 May 2009, 03:18 AM
The correct way to programmatically access column values is:

var dataitem = item as GridDataItem;
var value = dataitem["ColumnName"];

You can see more details in this online help article:
http://www.telerik.com/help/aspnet-ajax/grdaccessingcellsandrows.html

Hope that helps!
-Todd
Tags
Grid
Asked by
Armen
Top achievements
Rank 1
Answers by
Todd Anglin
Top achievements
Rank 2
Share this question
or