用Vs2013和SQL做教务管理系统时,其中要实现在学生登录界面登录后进入选课网页SelectCourse,选课界面有一个GridView控件绑定数据库显示课程信息。控件和运行后界面如图,


要实现点击“选修”后弹出另一个网页SelectCourse1用于返回学生用户信息和该课程信息(界面如图)

“选修”的代码如下:
<asp:TemplateField HeaderText=”选课”>
<ItemTemplate>
<a href=”#”onclick=”window.open(“SelectCourse1.aspx? cno=<%#Eval(“课程编号”) %>”,””,”width=500,height=500″)”>选修</a>
</ItemTemplate>
</asp:TemplateField>
SelectCourse网页有一段代码如下 :
protected void Page_Load(object sender, EventArgs e)
{
if (Session[“username”] == null)
{
this.form1.Visible = false;
WebMessage.Show(“请登录后方可进入!”,”../Index.aspx”);
}
else
{
if (Request.QueryString[“cno”] != null)
{
cno = Request.QueryString[“cno”].ToString();
}


要实现点击“选修”后弹出另一个网页SelectCourse1用于返回学生用户信息和该课程信息(界面如图)

“选修”的代码如下:
<asp:TemplateField HeaderText=”选课”>
<ItemTemplate>
<a href=”#”onclick=”window.open(“SelectCourse1.aspx? cno=<%#Eval(“课程编号”) %>”,””,”width=500,height=500″)”>选修</a>
</ItemTemplate>
</asp:TemplateField>
SelectCourse网页有一段代码如下 :
protected void Page_Load(object sender, EventArgs e)
{
if (Session[“username”] == null)
{
this.form1.Visible = false;
WebMessage.Show(“请登录后方可进入!”,”../Index.aspx”);
}
else
{
if (Request.QueryString[“cno”] != null)
{
cno = Request.QueryString[“cno”].ToString();
}
sno = Session[“username”].ToString();
ConnSql con = new ConnSql();
DataTable table = new DataTable();
table = con.RunSqlReturnTable(“select cno,cname,tname,skdd from course,teacher where course.tno=teacher.tno and cno=”” + cno + “””);
if (table.Rows.Count > 0)
{
Label1.Text = Session[“username”].ToString();
Label2.Text = Session[“sname”].ToString();
Label3.Text =table.Rows[0][0].ToString();
Label4.Text = table.Rows[0][0].ToString();
Label5.Text = table.Rows[0][0].ToString();
Label6.Text = table.Rows[0][0].ToString();
}
else
{
this.Label1.Text = “出现错误,请重新选!”;
}
}
}
结果发现参数并没有传过来,每次都是直接“出现错误,请重新选”,求高手解答疑惑
解决方案
10
检查下传入的cno能否正确
60
<a href=”#”onclick=”window.open(“SelectCourse1.aspx? cno=<%#Eval(“课程编号”) %>”,””,”width=500,height=500″)”>选修</a>
你设置querystring的地方?和cno之间有空格……
你设置querystring的地方?和cno之间有空格……
10
你把 Request.QueryString[“cno”] 打印出来看看