M
MattB
I've got an form (asp/vb.net) that might need a Checkboxlist or a
RadioButtonList, depending on some data in the database.
My implementation plan is this: have both controls on the page, but with
Visible=False. Once I can tell if I'll need the CheckBoxList or
RadioButtonList, I'd like to be able to assign the control to a
variable, like this:
-----
Dim myControl as System.Web.control
If bCanMultiSelect Then
myControl = myCheckBoxList
Else
myControl = myRadioButtonList
End If
With myControl
.Visible = True
.DataSource = dvFilteredList
.DataTextField = "descrip"
.DataValueField = "item"
.DataBind()
End With
-----
As you might guess, Intellisense doesn't like the myControl variable
being assigned like that and won't let me use it this way. Is there
something similar to get the desired results of having one reference
that could be wither type of control so I don't have to double all my
code setting and retrieving values from this control?
Thanks!
Matt
RadioButtonList, depending on some data in the database.
My implementation plan is this: have both controls on the page, but with
Visible=False. Once I can tell if I'll need the CheckBoxList or
RadioButtonList, I'd like to be able to assign the control to a
variable, like this:
-----
Dim myControl as System.Web.control
If bCanMultiSelect Then
myControl = myCheckBoxList
Else
myControl = myRadioButtonList
End If
With myControl
.Visible = True
.DataSource = dvFilteredList
.DataTextField = "descrip"
.DataValueField = "item"
.DataBind()
End With
-----
As you might guess, Intellisense doesn't like the myControl variable
being assigned like that and won't let me use it this way. Is there
something similar to get the desired results of having one reference
that could be wither type of control so I don't have to double all my
code setting and retrieving values from this control?
Thanks!
Matt