I have an aspx web form with various inputs including a dropdown box with 1-10. When the form is submitted a new panel is visible that has 10 rows of static textbox and label controls. These controls are all set to visible=false by default.
What I want is based on the number selected in the previous dropdown box, that is how many rows of controls I want to change to visible=true. The IDs for these controls are the same for each row apart from the last character which is to reflect what row they belong to. So row 1 would have the following:
ticketNum_Lbl_1
your_res_Txt_1
title_Txt_1
firstname_Txt_1
surname_Txt_1
ticketNum_Txt_1
What I wanted was a simple loop that would check the number at the end of the control’s ID and compare that to the number selected in the dropdown.
For clarity the dropdown list is for a user to select how many seats at a table they would like to book, the following screen would let them allocate names to the seats they are booking.
I have tried several things but am still obviously not getting it, although it might be something along the lines of:
Dim rowsNeeded As Integer = number_of_tickets_Ddl.SelectedValue
For a = 1 To rowsNeeded
Me.Controls("ticketNum_Lbl_" & a).Visible = True
Me.Controls("your_res_Txt_" & a).Visible = True
Me.Controls("title_Txt_" & a).Visible = True
Me.Controls("firstname_Txt_" & a).Visible = True
Me.Controls("surname_Txt_" & a).Visible = True
Me.Controls("ticketNum_Txt_" & a).Visible = True
Next
But this comes up with an error as the controls reference an index (integer) rather than a control’s name or ID (it seems?).
Any help appreciated.
You should use FindControl