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

[Solved] how to select a row programmatically

1 Answer 253 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Aykut
Top achievements
Rank 1
Aykut asked on 20 Jul 2009, 05:51 PM
Hi,
How can I set a row as selected by the datakey value from the code side?
If this is possible, should I also concern about paging?
Thanks.

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 21 Jul 2009, 04:14 AM
Hi Aykut,

Try  out the following code snippet to achieve the desired scenario. This will work with paging as well.

CS:
 
 protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            string strKey = item.GetDataKeyValue("ProductID").ToString(); 
            if (strKey == "11"
                item.Selected = true
        } 
    } 

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