how to get value from dropdownlist
hi,
I can not get the value from the dropdownlist, please help me. Thanks a lot.
Here my code
'Connect database
Dim DbPath As String = Server.MapPath("database.mdb")
Dim ConnStr As String
Dim SQL, b As String
Dim ds As DataSet
Dim a As Integer = 3
ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & DbPath & ";"
Dim MyOleDbConn As New OleDbConnection(ConnStr)
MyOleDbConn.Open()
'Select the project name from the current user
SQL = "SELECT * from project_investment where userID = 3"
Dim MyOleDbCommand As New OleDbCommand(SQL, MyOleDbConn)
Dim myda As New OleDbDataAdapter(MyOleDbCommand)
ds = New DataSet
myda.Fill(ds, "project_investment")
'Fill data in droplist
DropDownList1.DataSource = ds
DropDownList1.DataSource = ds.Tables(0)
DropDownList1.DataTextField = ds.Tables(0).Columns("Project_name").ColumnName.To String()
DropDownList1.DataValueField = ds.Tables(0).Columns("Project_Id").ColumnName.ToSt ring()
DropDownList1.DataBind()
Dim i As Integer
For i = 0 To DropDownList1.Items.Count - 1
DropDownList1.Items(i).Attributes.Add("style", ds.Tables(0).Rows(i)("Project_name").ToString())
Next
Sub projectrank()
Dim b As String
b = DropDownList3.SelectedItem.Text
Response.Write(b)
End Sub
Private Sub projectrank_next_ServerClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles projectrank_next.ServerClick
projectrank()
End Sub
|