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

Select Row

3 Answers 87 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Orit
Top achievements
Rank 1
Orit asked on 07 Jan 2010, 08:52 AM
Hello

I want to let the user find a row by the value of a specific column
this is the scenario-
the user write a text in a TextBox
and click search
then I take the text and find the row
(((System.Data.DataView)RadGridView1.ItemsSource).Table.Select("ActivityName like '%" + txtSearch.Text + "%' ")[0]) 
now I want to select this row
how can I do it?

3 Answers, 1 is accepted

Sort by
0
Milan
Telerik team
answered on 07 Jan 2010, 10:04 AM
Hi Orit,

Once you have found the data item you just need to set it as SelectedItem and it will be selected. For example:

var itemToSelect = (((System.Data.DataView)RadGridView1.ItemsSource).Table.Select("ActivityName like '%" + txtSearch.Text + "%' ")[0]);
this.myGrid.SelectedItem = itemToSelect;


Sincerely yours,
Milan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Orit
Top achievements
Rank 1
answered on 07 Jan 2010, 10:35 AM
I tried it
but it does not work
the SelectedItem is null.
0
Milan
Telerik team
answered on 07 Jan 2010, 11:45 AM
Hi Orit,

I guess that either the itemToSelect is null or it is not present in the ItemsSource that the grid is bound to. Since you are using a DataView I guess the grid is bound to a list of DataRowView items. If that is the case you will need to find the corresponding DataRowView (the Select method return a DataRow) item and set this item as SelectedItem. 


Kind regards,
Milan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
Orit
Top achievements
Rank 1
Answers by
Milan
Telerik team
Orit
Top achievements
Rank 1
Share this question
or