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

Selecting a specific row

1 Answer 89 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Stefan Larsson
Top achievements
Rank 1
Stefan Larsson asked on 08 Sep 2009, 11:56 AM
I have a problem where I need to select a specific row.
I have a unique ID in one of the cells for each row and this ID matches an int variable that I get returned from a function.

I currently tried

int root = %return value from function%
foreach (Telerik.WinControls.UI.GridViewDataRowInfo myrow in supportMailGV.Rows)
                    {
                        SupportMail sm = (SupportMail)myrow.DataBoundItem;
                        if (sm.RootIssue == root)
                        {
                            supportMailGV.SelectedRows[0] = myrow;
                            break;
                        }
                    }

to clalrify the names

SupportMailGV is a RadGridView filled with a list of the class (SupportMail)

What happens...

The loop will find the row that ha this RootIssue and by so we should know that wehave the correct row in the grid. but when I envoke the "supportMailGV.SelectedRows[0] = myrow;" the top line is the line that gets selected, even if the line that triggered and is stored in myrow is futher down the list.

is there a way to force selected row for this gridview?

1 Answer, 1 is accepted

Sort by
0
Stefan Larsson
Top achievements
Rank 1
answered on 08 Sep 2009, 02:27 PM
I solved it by using..


if (root != 0)
                    foreach (Telerik.WinControls.UI.GridViewDataRowInfo myrow in supportMailGV.Rows)
                    {
                        SupportMail sm = (SupportMail)myrow.DataBoundItem;
                        if (sm.RootIssue == root)
                        {
                            myrow.IsSelected = true;
                            break;
                        }
                    }
Tags
GridView
Asked by
Stefan Larsson
Top achievements
Rank 1
Answers by
Stefan Larsson
Top achievements
Rank 1
Share this question
or