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

Access to underlying data

2 Answers 63 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bob Fenton
Top achievements
Rank 1
Bob Fenton asked on 08 Jun 2010, 08:01 PM
Hi

Is it possible to access data which is in the data table bound to the grid but where the grid column for that data has a visible property of false?

For example, I want to do some custom formatting on Cell A based on the value of Cell B, where the column for Cell B's values is not visible in the grid.

Thanks

Bob

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 09 Jun 2010, 06:11 AM
Hello Bob,

It is possible to access the cell value even if it's visible property is set to false. Check out the following code snippet.

ASPX:
 
 <telerik:GridBoundColumn UniqueName="FirstName" DataField="FirstName" HeaderText="FirstName"
 </telerik:GridBoundColumn> 
 <telerik:GridBoundColumn UniqueName="user_role" DataField="user_role" HeaderText="user_role" Visible="false"
 </telerik:GridBoundColumn> 

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            if (item["user_role"].Text == "admin"
            { 
                item["FirstName"].Text = "New Name"
            } 
        } 
    } 

You can also refer the following documentation which describes how to access cells and rows in a grid.
Accessing cells and rows



Regards,
Shinu.

0
Bob Fenton
Top achievements
Rank 1
answered on 09 Jun 2010, 06:09 PM
Perfect!

Thanks very much.

Bob
Tags
Grid
Asked by
Bob Fenton
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Bob Fenton
Top achievements
Rank 1
Share this question
or