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

Select record after filter

3 Answers 45 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David Boylan
Top achievements
Rank 2
David Boylan asked on 20 Nov 2008, 05:11 PM
Hi All

I have hopefully a simple question about filtering.  After performing a filter opetation on a grid, if only one record is return I want to automatically select that item.  Is there a event I can capture ater filtering completes to do this ?

Cheers

3 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 21 Nov 2008, 05:36 AM
Hi,

You can try the following code snippet to achieve the desired scenario.

CS:
 protected void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
        int count=RadGrid1.MasterTableView.Items.Count; 
         
        if (count == 1) 
        { 
            foreach (GridDataItem item in RadGrid1.MasterTableView.Items) 
            { 
                item.Selected = true
            }  
        } 
      
    } 


Thanks
Shinu.
0
David Boylan
Top achievements
Rank 2
answered on 21 Nov 2008, 11:34 AM
Thanks
0
Princy
Top achievements
Rank 2
answered on 21 Nov 2008, 11:58 AM
Hi  Geoff Airey,

You can also try selecting the item using the following approach instead of looping through the entire rows.

CS:
        int count=RadGrid1.MasterTableView.Items.Count;  
        if (count == 1)  
            RadGrid1.MasterTableView.Items[0].Selected = true


Princy.
Tags
Grid
Asked by
David Boylan
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
David Boylan
Top achievements
Rank 2
Princy
Top achievements
Rank 2
Share this question
or