dropdownlist控件的问题,在线急等
在gridview里显示学生信息,在gridview里添加了一个超链接按钮 "修改 ",点击修改就会跳转到修改页面进行修改,在修改页面有dropdownlist控件,已经在修改页面的page_load事件里连接上数据库里面的班级表了,当在gridview点击修改链接时就会在dropdownlist控里面显示相应的班级,其他项会在文本框控件中显示,向各位请教如何在dropdownlist控件里面显示相应班级;之前都没能解决
这是在修改页面连接班级的代码
Dim sql As String
Dim conn As New SqlConnection
conn.ConnectionString = "data source=192.168.31.199;initial catalog=kaoqin manager;user id=james5;password=james5; "
sql = "select classno,classname from class "
Dim cmd As New SqlCommand(sql, conn)
conn.Open()
Dim dr As SqlDataReader
dr = cmd.ExecuteReader()
banji.AppendDataBoundItems = True
banji.Items.Add(New ListItem( "--请选择-- ", "-1 "))
banji.DataSource = dr
banji.DataValueField = "classno "
banji.DataTextField = "classname "
banji.DataBind()
这是传递参数的代码
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Page.IsPostBack = False Then
Dim conn As New SqlConnection
conn.ConnectionString = "data source=192.168.31.199;initial catalog=kaoqin manager;user id=james5;password=james5; "
Dim sql As String
sql = "select kaoqinno,riqi,hour,remark ,stuname ,mattername,classname from "
sql &= "kaoqin,class,matter where kaoqin.classno=class.classno and kaoqin.matterno=matter.matterno "
sql &= " and kaoqinno= " & Request.QueryString( "kaoqinno ")
Dim cmd As New SqlCommand(sql, conn)
co