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

[Solved] select rows from gridview

3 Answers 154 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Hector
Top achievements
Rank 1
Hector asked on 09 Jun 2009, 01:18 PM
Hello, I am looking for a way to selecting multiple rows from a GridView where column = "xxxx"  I would like to select all the rows that belong to a certain Group, and Group is an item in the bound datasource. 
Thanks.

3 Answers, 1 is accepted

Sort by
0
Hector
Top achievements
Rank 1
answered on 09 Jun 2009, 06:30 PM
Here is what I came up with.  It works, but there might be a more efficient way.

private void cmbSelectGroup_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangedEventArgs e)  
        {  
            if (cmbSelectGroup.Text == "Select By Groups:")  
                return;  
            gridMultiSelect_accounts.UnselectAll();  
            foreach (DataRecord r in gridMultiSelect_accounts.Records)  
            {  
                AccountValidValues acct = (AccountValidValues) r.Data;  
                if (acct.GroupName == cmbSelectGroup.SelectedItem.ToString())  
                {  
                    gridMultiSelect_accounts.FindRecord(acct).IsSelected = true;  
                }  
            }  
              
        } 

0
Pavel Pavlov
Telerik team
answered on 12 Jun 2009, 12:33 PM
Hello Hector,

Your approach seems to be fine. I have just one suggestion :

I believe you can replace :
gridMultiSelect_accounts.FindRecord(acct).IsSelected = true;

with r.IsSelected = true

This may increase the performance a little bit.

Greetings,
Pavel Pavlov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Hector
Top achievements
Rank 1
answered on 12 Jun 2009, 02:49 PM
Oh, yeah.  Thanks :-)
Tags
GridView
Asked by
Hector
Top achievements
Rank 1
Answers by
Hector
Top achievements
Rank 1
Pavel Pavlov
Telerik team
Share this question
or