This is a migrated thread and some comments may be shown as answers.
Cast GridViewRow to specified object
1 Answer 29 Views
This is a migrated thread and some comments may be shown as answers.
Andrei
Top achievements
Rank 2
Andrei asked on 28 May 2012, 09:01 AM
Hi,

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 ?



1 Answer, 1 is accepted

Sort by
0
Stoich
Telerik team
answered on 04 Jun 2012, 07:47 AM
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,
Stoich
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Asked by
Andrei
Top achievements
Rank 2
Answers by
Stoich
Telerik team
Share this question
or