在线等,一个困绕我很久的问题
在gridview里显示学生信息,在gridview里添加了一个超链接按钮 "修改 ",点击修改就会跳转到修改页面进行修改,在修改页面有dropdownlist控件,已经在修改页面的page_load事件里连接上数据库里面的班级表了,dropdownlist控件里面可以显示出相应的班级出来,当在gridview点击修改链接时就会在dropdownlist控里面显示相应的班级,其他项会在文本框控件中显示,以前也请教过别人,但是别人给的代码不报错.也不会执行相应的操作.现在把代码重新贴出来.希望大家帮忙解决
这是修改页面获得参数的代码,并在控件中显示出来
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=127.0.0.1;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)
conn.Open()
Dim dr As SqlDataReader = cmd.ExecuteReader
If dr.Read Then
xingming.Value = dr.Item( "stuname ").ToString
riqi.Value = DateTime.Parse(dr.Item( "riqi ")).ToString( "yyyy-MM-dd ")
keshi.Value = dr.Item( "hour ").ToString
beizhu.Value = dr.Item( "remark ").ToString
Dim item As ListItem
item = banji.Items.FindByText(dr.Item( "classname ").ToString)