digimortal
Programmer
Hi,
I'm creating a number of radiobuttonlists at runtime and assign them different IDs but when I try to access them using FindControl, it can not find them:
This is what I'm trying to do
and this is how I create them:
and I create them at a button click event..
By the way I don't know how to access the value of a dynamically created control...
Please Help..
Thnx in advance
I'm creating a number of radiobuttonlists at runtime and assign them different IDs but when I try to access them using FindControl, it can not find them:
This is what I'm trying to do
Code:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim myControl1 As Control = FindControl("HoSe1")
If (Not myControl1 Is Nothing) Then
Label1.Text = myControl1.NamingContainer.ID.ToString
Else
Label1.Text = "Control not found....."
End If
End Sub
Code:
Dim HType As New TableCell
Dim HourSelect As New RadioButtonList
HourSelect.ID = "HoSe" & i
HType.BackColor = HType.BackColor.FromArgb(204, 204, 255)
HType.ForeColor = HType.ForeColor.Black
HType.Font.Bold = True
HourSelect.RepeatDirection = HourSelect.RepeatDirection.Horizontal
HourSelect.CellPadding = 3
HourSelect.CellSpacing = 3
HourSelect.DataValueField = WorkHoursDS1.WorkHours.TypeIDColumn.ToString
HourSelect.DataTextField = WorkHoursDS1.WorkHours.TypeNameColumn.ToString
HourSelect.ForeColor = HourSelect.ForeColor.White
HourSelect.Font.Bold = True
HourSelect.DataSource = WorkHoursDS1.WorkHours
HourSelect.DataBind()
RadioButtonList1.DataBind()
HType.Controls.Add(HourSelect)
Table3.Rows(i).Cells.Add(HType)
By the way I don't know how to access the value of a dynamically created control...
Please Help..
Thnx in advance