vedi se ti può servire
codice:
<form id="Form1" method="post" runat="server">
<SELECT id="Select1" name="Select1" runat="server"></SELECT>
<asp:Button id="Button2" runat="server" Text="Refresh"></asp:Button>
</form>
codice:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Inserire qui il codice utente necessario per inizializzare la pagina
If Not Me.IsPostBack Then
BindData()
End If
End Sub
Private Sub BindData()
Dim dt As DataTable = Libreria.GetDataTable(StringaConnessione, "SELECT ID, TESTO FROM CAMPI ORDER BY ID")
Me.Select1.DataSource = dt
Me.Select1.DataTextField = "testo"
Me.Select1.DataValueField = "id"
Me.Select1.DataBind()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'stampo il value
PrintLn(Me.Select1.Items.Item(Me.Select1.SelectedIndex).Value)
'stampo il Text
PrintLn(Me.Select1.Items.Item(Me.Select1.SelectedIndex).Text)
'stampo il value
PrintLn(Me.Select1.Value)
End Sub