J
Jeff
Hi -
I'm creating a web control library (using VB.NET), and I'm trying to add a
modified asp:dropdownlist control to it.
How do I add asp:ListItems to the dropdownlist (within the web control
library control)?
My code follows below (and it doesn't work). When I add the control to an
aspx page, I simply get a string of the concatenated values ("First
ValueSecond ValueThird Value") displayed; no dropdownlist.
Thanks for your help.
- Jeff
<DefaultProperty("SelectedValue"), ToolboxData("<{0}:TestList
runat=server></{0}:TestList>")> Public Class TestList
Inherits System.Web.UI.WebControls.DropDownList
Dim _selected As String
<Bindable(True), Category("Data"), DefaultValue("AA")> Overrides
Property [SelectedValue]() As String
Get
Return _selected
End Get
Set(ByVal Value As String)
_selected = Value
End Set
End Property
Protected Overrides Sub Render(ByVal output As
System.Web.UI.HtmlTextWriter)
Dim strTxt as String
strTxt = ""
strTxt &= "<aspropDownList id='ddlList' runat='server'>"
strTxt &= "<asp:ListItem Value='AA'"
If [SelectedValue] = "AA" Then strTxt &= " Selected='True'"
strTxt &= ">First Value</asp:ListItem>"
strTxt &= "<asp:ListItem Value='BB'"
If [SelectedValue] = "BB" Then strTxt &= " Selected='True'"
strTxt &= ">Second Value</asp:ListItem>"
strTxt &= "<asp:ListItem Value='CC'"
If [SelectedValue] = "CC" Then strTxt &= " Selected='True'"
strTxt &= ">Third Value</asp:ListItem>"
strTxt &= "</aspropDownList>"
output.Write(strTxt)
End Sub
End Class
I'm creating a web control library (using VB.NET), and I'm trying to add a
modified asp:dropdownlist control to it.
How do I add asp:ListItems to the dropdownlist (within the web control
library control)?
My code follows below (and it doesn't work). When I add the control to an
aspx page, I simply get a string of the concatenated values ("First
ValueSecond ValueThird Value") displayed; no dropdownlist.
Thanks for your help.
- Jeff
<DefaultProperty("SelectedValue"), ToolboxData("<{0}:TestList
runat=server></{0}:TestList>")> Public Class TestList
Inherits System.Web.UI.WebControls.DropDownList
Dim _selected As String
<Bindable(True), Category("Data"), DefaultValue("AA")> Overrides
Property [SelectedValue]() As String
Get
Return _selected
End Get
Set(ByVal Value As String)
_selected = Value
End Set
End Property
Protected Overrides Sub Render(ByVal output As
System.Web.UI.HtmlTextWriter)
Dim strTxt as String
strTxt = ""
strTxt &= "<aspropDownList id='ddlList' runat='server'>"
strTxt &= "<asp:ListItem Value='AA'"
If [SelectedValue] = "AA" Then strTxt &= " Selected='True'"
strTxt &= ">First Value</asp:ListItem>"
strTxt &= "<asp:ListItem Value='BB'"
If [SelectedValue] = "BB" Then strTxt &= " Selected='True'"
strTxt &= ">Second Value</asp:ListItem>"
strTxt &= "<asp:ListItem Value='CC'"
If [SelectedValue] = "CC" Then strTxt &= " Selected='True'"
strTxt &= ">Third Value</asp:ListItem>"
strTxt &= "</aspropDownList>"
output.Write(strTxt)
End Sub
End Class