ドロップダウンがあり、データソースがあり、空白のデータを追加したかったのですが、選択した値は常に 0 でした
私のコードビハインド:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
listhostel()
End Sub
Protected Sub listhostel()
Dim dash As New DataSet
Dim clas As New Class1
dash = clas.returndataset("select ID as idhostel,Nama from Hostel")
listhotelx.DataSource = dash
listhotelx.DataBind()
listhotelx.Items.Insert(0, New ListItem("-- Select --", 0))
End Sub
Protected Sub viewdatagrid_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles viewdatagrid.Click
Label1.Text = listhotelx.SelectedValue
viewdata()
End Sub
ファイル.aspx
<asp:DropDownList ID="listhotelx" runat="server" DataTextField="Nama"
DataValueField="idhostel" >
</asp:DropDownList>