Raising event from run-time dropdownlist

A

Andrew Morton

I'm creating DropDownList controls at run-time, and I've found I have to add
the onchange event myself (.Attributes.Add(...) below).

Is that the way it's meant to happen, or have I missed something that would
automatically add the onchange event?

U = New DropDownList
With U
.DataSource = dv
.DataTextField = "myChoice"
.DataValueField = "myValue"
.DataBind()
' n is the number of this control
.ID = "U_" & n.ToString
' select the current value
For k As Integer = 0 To UBound(usageValues)
If CStr(entry("usage")) = usageValues(k) Then
.SelectedIndex = k
Exit For
End If
Next
AddHandler .SelectedIndexChanged, AddressOf
ModifyUsage_SelectedIndexChanged
.Attributes.Add("onchange", "__doPostBack('U_" & n.ToString & "')")
End With

Andrew
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top