我有一个下拉列表,我有一个数据源,我想添加它工作的空白数据,但选择的值始终为 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>