In many forums, I used to see people asking for code to bind the dropdown list from basic collections. Here is the code to bind a Hash Table to ASP:Dropdown list, and setting the value of the selected item to the Text box. This is in ASP.Net 1.1.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Dim students As New Hashtable
students.Add("1", "Student1")
students.Add("2", "Student2")
students.Add("3", "Student3")
students.Add("4", "Student4")
students.Add("5", "Student5")
StudentDropdown.DataTextField = "Value"
StudentDropdown.DataValueField = "key"
StudentDropdown.DataSource = students
StudentDropdown.DataBind()
End If
End Sub
And set the Autopostback property of the StudentDropdown to True. And in the SelectedIndexChanged event, write the code to set the value of the Dropdown to the Textbox.
Protected Sub StudentDropdown_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles StudentDropdown.SelectedIndexChanged
If uxSample.SelectedIndex <> -1 Then
StudentId.Text = StudentDropdown.Items(StudentDropdown.SelectedIndex).Value
End If
End Sub