I have an ASP.NET web page that dynamically creates a table with 3 columns and a variable number of rows.
Col 1 contains a checkbox - chkx
Col 2 contains a textbox - txtx
Col 3 contains a label - lblx
is a number based on how many times we've ran round the loop.
All the above are created dynamically during the page init event and are givin an ID at run-time. (code snipit below)
Everything works fine, however, when I click one of the checkboxes I need to get the value in the coresponding textbox & label
i.e. when I click chk1, then I need the value in txt1 & lbl1, but as the controls are dynamic, the code behind doesn't recognise the ID of the control, so... txt1.Text fails validation..
So how do I reference the control's value
Dim nCheckBox As CheckBox = New CheckBox()
nCheckBox.Checked = False
nCheckBox.EnableViewState = True
nCheckBox.ID = "chk" & counter
nCheckBox.AutoPostBack = True
AddHandler nCheckBox.CheckedChanged, AddressOf CheckBox1_CheckedChanged