by Jarkko Tur » Wed, 15 Feb 2006 15:39:43
ere is the code that creates the radiobuttonlist:
Dim typeofbuttonlist As Integer = myrow2.Item("TYPEOFBUTTONLIST")
c = New HtmlTableCell
Select Case typeofbuttonlist
Case 1
Dim name As String = "r" & kysymysnumero
Dim radio As New RadioButtonList
radio.ID = name
radio.RepeatDirection = RepeatDirection.Horizontal
radio.Items.Add(New ListItem("1", "1"))
radio.Items.Add(New ListItem("2", "2"))
radio.Items.Add(New ListItem("3", "3"))
radio.Items.Add(New ListItem("4", "4"))
radio.Items.Add(New ListItem("5", "5"))
c.Controls.Add(radio)
Case 2
Dim name As String = "r" & kysymysnumero
Dim radio As New RadioButtonList
radio.ID = name
radio.RepeatDirection = RepeatDirection.Horizontal
radio.Items.Add(New ListItem("4", "4"))
radio.Items.Add(New ListItem("5", "5"))
radio.Items.Add(New ListItem("6", "6"))
radio.Items.Add(New ListItem("7", "7"))
radio.Items.Add(New ListItem("8", "8"))
radio.Items.Add(New ListItem("9", "9"))
radio.Items.Add(New ListItem("10", "10"))
c.Controls.Add(radio)
Case 3
Dim name As String = "r" & kysymysnumero
Dim radio As New RadioButtonList
radio.ID = name
radio.RepeatDirection = RepeatDirection.Horizontal
radio.Items.Add(New ListItem("x", "1"))
radio.Items.Add(New ListItem("y", "2"))
c.Controls.Add(radio)
Case 4
Dim name As String = "r" & kysymysnumero
Dim radio As New RadioButtonList
radio.ID = name
radio.RepeatDirection = RepeatDirection.Horizontal
radio.Items.Add(New ListItem("yes", "1"))
radio.Items.Add(New ListItem("no", "2"))
c.Controls.Add(radio)
Case 5 ' creates a textbox
Dim name As String = "t" & kysymysnumero
Dim txtbox As New TextBox
txtbox.ID = name
txtbox.Width = 300
txtbox.Height = 100
txtbox.MaxLength = 500
txtbox.TextMode = TextBoxMode.MultiLine
c.Controls.Add(txtbox)
End Select
r.Cells.Add(c)
-----------------------
Dim radio As RadioButtonList, Con4 As Control
For Each radio In con4.Controls <---------------
name = radio.ID
value = radio.SelectedItem.value
Next
This is the line that causes the error Unable to cast object of type
'System.Web.UI.LiteralControl' to type
'System.Web.UI.WebControls.RadioButtonList'.
There are three types of controls in the form: Literalcontrols,
Radiobuttonlists and Textboxes.
Thank you for replying to my post. I would be very happy if you could help.
Toni Sevastjanoff
"Christopher Reed" < XXXX@XXXXX.COM > kirjoitti
viestiss XXXX@XXXXX.COM ...
>> Show the code that creates your dynamic RadioButtonLists. Indicate which
>> line is receiving the error message.
>> --
>> Christopher A. Reed
>> "The oxen are slow, but the earth is patient."
>>
>> "Jarkko Turpeinen"<< XXXX@XXXXX.COM >> wrote in message
>> news: XXXX@XXXXX.COM ...
>>> I'm developing a project that dynamically creates a set of
>>> radiobuttonlist controls. I have a problem with reading the values of the
>>> radiobuttons. When I'm using the following code to iterate through