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

Selecting GridView row with specific value

3 Answers 113 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Aaron
Top achievements
Rank 1
Aaron asked on 08 Apr 2016, 06:26 PM

I have currently have a GridView that contains a list of queries. I need to be able to search through the GridView, and run a specific query based on the text data in a specific column. There are currently enough rows of data in the grid that there is a scrollbar. 

Any way to do this without having to set a filter on the grid column I want and select the first row?

3 Answers, 1 is accepted

Sort by
0
Elena
Telerik team
answered on 13 Apr 2016, 12:09 PM
Hello Aaron,

Thank you for contacting us. 

Some further clarification will be required to be able to advise you best. Please let me know what are the actions to execute after you find the particular element. In case it is to simply click on that element this could be easily obtained with a coded step. 

Please elaborate further more on the exact scenario you need to play. 

Looking forward to hearing from you. 

Regards,
Elena Tsvetkova
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Aaron
Top achievements
Rank 1
answered on 13 Apr 2016, 12:14 PM

The idea was to select a row from the gridview with text in a specific column, and then to click a button to run an application command based on the selected row.

 

We decided to make a unique column in the view, and we use the element that's click on to search for the unique text.

 

Although for future reference, what would be an easy way to do this with a coded step? I was having a hard time finding anything on it.

0
Boyan Boev
Telerik team
answered on 18 Apr 2016, 11:03 AM
Hello Aaron,

Here is an example code against our grid demo page. It finds the first row which contains "Opel" and then finds a button inside that row.

RadGrid grid = ActiveBrowser.Find.ById<RadGrid>("ctl00_ContentPlaceholder1_RadGrid1");
System.Threading.Thread.Sleep(1000);
grid.Refresh();
foreach (HtmlTableRow row in  grid.MasterTable.AllRows)
{
 if(row.InnerText.Contains("Opel"))
{
//This is only an example of how to find a button inside of the row (i.e. there is no button in the demo gird hence this piece of code will fail).
HtmlInputButton myButton = row.Find.ById<HtmlInputButton>("HtmlInputButton").MouseClick();                   
   break;
}
}

Let me know if that helps.

Regards,
Boyan Boev
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
Aaron
Top achievements
Rank 1
Answers by
Elena
Telerik team
Aaron
Top achievements
Rank 1
Boyan Boev
Telerik team
Share this question
or