我想获取从dropdownlist里选择的值,但里面的值显示的却是:system.data.row(),不知道怎么回来,各位帮我看一下:
另说明:type是一个表,productlist也是一个表,typeid是type表的主键,是productlist的从键.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'在此处放置初始化页的用户代码
Dim conn As New SqlConnection("server=(local);database=xf;uid=sa;pwd=;")
Dim cmd As New SqlCommand("select typename from type", conn)
Dim adp As New SqlDataAdapter(cmd)
Dim ds As New DataSet
adp.Fill(ds, "type")
dplist.DataSource = ds
dplist.DataBind()
End Sub
Sub tj_click(ByVal sender As Object, ByVal e As EventArgs)
Dim conn As New SqlConnection("server=(local);database=xf;uid=sa;pwd=997mb;")
Dim str As String = "insert into productlist(pro_id,productname,typeid) values('" & TextBox1.Text & "','" & TextBox2.Text & "','" & dplist.SelectedItem.Value & "')"
If Trim(TextBox1.Text) <> "" Or Trim(TextBox2.Text) <> "" Or Trim(dplist.SelectedItem.Text) <> "" Then
Dim cmd As New SqlCommand(str, conn)
Dim exp As Exception
Try
conn.Open()
cmd.ExecuteNonQuery()
conn.Close()
Response.Write("成功插入记录!")
Catch exp
Label1.Text = "发生错误,没有正常插入记录!"
End Try
End If
End Sub