Cast GridViewRow to specified object

2 posts, 0 answers
  1. Andrei
    Andrei avatar
    12 posts
    Member since:
    Mar 2012

    Posted 28 May 2012 Link to this post


    I have a code:
    RadGridView usersGrid = app.VisualTree.Find.ByName<RadGridView>("usersGrid");
                    Assert.IsNotNull(usersGrid, "users grid not found");
                    usersGrid.Wait.For(ag => ag.As<RadGridView>().Rows.Count > 0, timeout, "Rows not found");
                    Assert.IsTrue(usersGrid.Rows.Count > 0, "users grid contains 0 rows");
                    //double click on randomize row
                    usersGrid.Rows[0].User.Click(ArtOfTest.WebAii.Core.MouseClickType.LeftClick, new System.Drawing.Point(10, 10));

                    var qwe = usersGrid.SelectedItem;
                    var qwe1 = usersGrid.SelectedItem as Models.User;


    "usersGrid" are binding from a List<Models.User>. I want to convert selected row to "Models.User"

    In result I have that type of "qwe" = "Models.User", but "qwe1" is NULL.
    It's possibly solve this problem ?

  2. Stoich
    Stoich avatar
    1 posts

    Posted 04 Jun 2012 Link to this post

    Hi Andrei,
    I reviewed your code. As far as I can tell the most likely problem is that the following conversion:
    var qwe1 = usersGrid.SelectedItem as Models.User;
    is not possible.

    However, the type Models.User is something you've defined yourself. Without seeing the definition for this type, it's not possible to determine why the conversion is not working.

    All the best,
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top