Selecting GridView row with specific value

4 posts, 0 answers
  1. Aaron
    Aaron avatar
    5 posts
    Member since:
    Apr 2016

    Posted 08 Apr Link to this post

    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?

  2. Elena Tsvetkova
    Admin
    Elena Tsvetkova avatar
    251 posts

    Posted 13 Apr Link to this post

    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!
  3. Aaron
    Aaron avatar
    5 posts
    Member since:
    Apr 2016

    Posted 13 Apr in reply to Elena Tsvetkova Link to this post

    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.

  4. Boyan Boev
    Admin
    Boyan Boev avatar
    1039 posts

    Posted 18 Apr Link to this post

    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!
Back to Top