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,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top