actually i given like this, but for 1 dropdown it is ok, the selected item id displaying. but i want to display 5 dropdown and for the 5 dropdown the selecteditem should display in label in next next line. that is i want to loop through. how to do that.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim ComboBox As DropDownList = New DropDownList()
ComboBox.ID = "ComboBox"
ComboBox.AutoPostBack = True
ComboBox.Items.Add(New ListItem("Year: 2010", "2010"))
ComboBox.Items.Add(New ListItem("Year: 2011", "2011"))
ComboBox.Items.Add(New ListItem("Year: 2012", "2012"))
ComboBox.Items.Add(New ListItem("Year: 2013", "2013"))
ComboBox.Items.Add(New ListItem("Year: 2014", "2014"))
AddHandler ComboBox.SelectedIndexChanged, AddressOf Dynamic_Method
Me.form1.Controls.Add(ComboBox)
End Sub
Private Sub Dynamic_Method(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim ComboBox As DropDownList = CType(sender, DropDownList)
Dim sSTR As String = ""
sSTR = "</br>Selected Index: " + ComboBox.SelectedIndex.ToString()
sSTR += "</br>Selected Item: " + ComboBox.SelectedItem.Text.ToString()
sSTR += "</br>Selected Value: " + ComboBox.SelectedItem.Value.ToString()
Dim lbl As Label = New Label()
lbl.Text = sSTR
End Sub