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

How to find value in hidden field in grid/table

2 Answers 75 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Cheryl
Top achievements
Rank 1
Cheryl asked on 03 Apr 2012, 04:22 AM
Hi

I have a datagrid/table where for each row (except the header) there are some hidden values, some showng info and a button.

What I'm wanting to do is loop through the rows and find in the first column the values in 2 hidden fields.  If hidden1 and hidden2 match datavalue1 and datavalue2 then I can find the correct rowindex and therefore find the correct button to click.

I can successfully loop through the rows of the table, but i'm not sure how to find the value of the hidden fields for EACH row as I loop through.

I can find it on the page using

Dim cpolicy As HtmlInputHidden = Pages.TravelInsuranceSalesSystem1.Get(Of HtmlInputHidden)("id=ctl00_ContentPlaceHolder1_TestGrid_ctl02_cpolicy")


but not for each cell as I'm unsure how to refer to a partial ID for a hidden field.

This is what I have so far, the htmlinputhidden is incorrect:

For Each r As HtmlTableRow In Pages.TravelInsuranceSalesSystem1.ContentPlaceHolder1TestGridTable.AllRows
               if r.RowIndex <> 0 then
       'ignore the header row
                   For Each c As HtmlTableCell In r.Cells
                        
                           if c.CellIndex = 0 then
                           'column 1 only
                                    
                               Dim cpolicy As HtmlInputHidden = c.Get(Of HtmlInputHidden)("id=~cpolicy")
                                
                               if cpolicy.Equals("TI") then
                                   Log.WriteLine("cpolicy:" & cpolicy.Value )
                               end if
                           end if
                   Next
               end if
           Next

2 Answers, 1 is accepted

Sort by
0
Cheryl
Top achievements
Rank 1
answered on 04 Apr 2012, 04:56 AM
FYI

I've managed to find a solution for this. Instead of this

Dim cpolicy As HtmlInputHidden = c.Get(Of HtmlInputHidden)("id=~cpolicy")

I'm using this which works:

Dim cpolicy As HtmlInputHidden = Pages.TravelInsuranceSalesSystem1.Get(Of HtmlInputHidden)("id=ctl00_ContentPlaceHolder1_TestGrid_ctl0" & r.rowindex + 1 & "_cpolicy")

 

 

 


0
Anthony
Telerik team
answered on 04 Apr 2012, 06:36 PM
Hello Cheryl,

We're glad you found a solution. Let us know if you require further assistance.

Kind 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
Cheryl
Top achievements
Rank 1
Answers by
Cheryl
Top achievements
Rank 1
Anthony
Telerik team
Share this question
or