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

Getting the RowIndex of clicked row in gridviewrow

1 Answer 68 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Lukasz
Top achievements
Rank 1
Lukasz asked on 09 May 2012, 09:36 AM
{
(...) # get data from sql
Random r = new Random(); int val = r.Next(0, t.Rows.Count - 1); var row = t.Rows[val]; GridViewRow ro = Pages.App.SilverlightApp.Get<GridViewRow>("TextContent=" + row[0].ToString(), "XamlTag=textblock"); Debug.WriteLine("Index: " + ro.Index.ToString());
ro.User.Click(MouseClickType.LeftDoubleClick);
} Can someone tell me how can I get the Index, RowIndex of this (ro) row. From
Debug.WriteLine("Index: " + ro.Index.ToString());
I get always "0".

1 Answer, 1 is accepted

Sort by
0
Anthony
Telerik team
answered on 09 May 2012, 04:28 PM
Hello Lukasz,

The issue is that your variable ro is actually returning a TextBlock, and its index is 0.

Instead you can get the TextBlock, then find its parent GridViewRow and log its index:

Random r = new Random();
int val = r.Next(0, grid.Rows.Count - 1);
GridViewRow row = grid.Rows[val];
GridViewCell cell = row.Cells[0];
string t = cell.TextBlockContent;
 
TextBlock tb = Pages.TelerikComboBoxFor.SilverlightApp.Get<TextBlock>("textcontent=" + t);
GridViewRow ro = tb.Parent<GridViewRow>();
 
Log.WriteLine("Index: " + ro.Index.ToString());
ro.User.Click(MouseClickType.LeftDoubleClick);


Regards,
Anthony
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Tags
General Discussions
Asked by
Lukasz
Top achievements
Rank 1
Answers by
Anthony
Telerik team
Share this question
or