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

[Solved] Select Row Based on a Column Value

1 Answer 100 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dick
Top achievements
Rank 1
Dick asked on 02 Jul 2009, 10:11 PM
Hi -

I have a data item that I would like to compare to a column's value for every row in the grid.  When there is a match, I would like to set column's corresponding row's selected property to true.  (Server side code)

the pseudo code would be

For each grid(row) in mastergrid
    when activityid == grid(row).Column(activityid.value) 
         set the grid(row) selected.property = true.
         quit

Could you provide a code example of how this can be accomplished?
Thanks

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 03 Jul 2009, 05:03 AM
Hello,

You can try out the following code to select the row based on a value:
c#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            foreach (GridColumn col in RadGrid1.MasterTableView.RenderColumns) 
            { 
                if (item[col.UniqueName].Text == activityid)                
                    item.Selected = true;                 
            }             
        } 
   } 

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