Trouble referencing controls within list controls

2

2obvious

I have a DataGrid containing a TextBox control and a CustomValidator
in each row.

The CustomValidator fires a function that compares all TextBoxes for
equality. The

algorithm for comparison is straightforward:

*PSEUDOCODE*

for i=1 thru ( Container.Length-1 )
for j=i+1 thru ( Container.Length-1 )
if ( TextBox==TextBox[j] )
TRUE

It would be even faster if instead of starting with 1 everytime, I set
i to get the

index of the current Container row.

Problem is I'm having trouble referencing the TextBoxes within the
DataGrid. I've

studied msdn

(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtskref

erencingcontrolsinwebformspages.asp) but the concept still baffles me.

Specifically, what I try to do is store the TextBoxes for comparison
in an array:

Dim ControlName As String ' temporary

ControlName = OurDataGrid.Controls(i).UniqueID
aObjFirst(0) = CType( Me.FindControl(ControlName & "First"), TextBox
)
ControlName = OurDataGrid.Controls(j).UniqueID
aObjFirst(1) = CType( Me.FindControl(ControlName & "First"), TextBox
)

' If first names match...
If ( aObjFirst(0).Text=aObjFirst(1).Text ) Then
...

(Yes, I'm comparing first names.) However, this always warns me that
j is out of

range. And getting back to the msdn, it seems to be discouraging the
technique of

name concatenation I used to get at the controls I want.

Can anyone follow where I'm going with this and provide some
insightful direction?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top