最近在做数据库的课设。..
小组课题是校友录
现在碰到了个棘手的问题。..按我的思想是一个学校对于的自己的留言板,当用户进入学校S1的留言板时,只看到在本校留言板的留言
代码如下:
留言板的
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;public partial class board : System.Web.UI.Page

        protected void Page_Load(object sender, EventArgs e)
    {
        if(!IsPostBack)
        {
            setbind();
           string u_sname;
           u_sname = Request["u_sname"];   
    
        }
       
        }
    private void setbind()
    {
        SqlConnection conn = new SqlConnection("Server=localhost;database=students;user=sa;password=");        string str = "select * from message where u_sname=" + Request["u_sname"];
        SqlDataAdapter da = new SqlDataAdapter(str, conn);
        DataSet ds = new DataSet();
        da.Fill(ds, "message");
        DataTable dt = ds.Tables["message"];
        DataList1.DataSource = dt;
        DataList1.DataBind();
    }
   
   /* protected void Button1_Click(object sender, EventArgs e)
    {
        string Name = Session["Username"].ToString();
        string insCmd = "insert into message values(" +Request["PostID"] + ",getdate())";
        SqlCommand myCmd = new SqlCommand(insCmd, myConnection);
        myCmd.Connection.Open();
        myCmd.ExecuteNonQuery();
        myCmd.Connection.Close();
        myConnection.Close();
        BindData();
       
    }*/
    protected void Button1_Click(object sender, EventArgs e)
    {
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
    }
    
}
这是进入留言板的Html代码
 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
</head>
<body>
<center><h5>查找已注册用户</h5>
    <asp:HyperLink ID="HyperLink2"  NavigateUrl="~/users.aspx" runat="server">查找</asp:HyperLink></center>
    <form id="form1" runat="server">
    <div>
    <asp:DataList ID="DataList1" runat="server"  BorderColor="White" BorderStyle="Ridge" BorderWidth="2px" CellPadding="1" CellSpacing="1" HorizontalAlign="Center" >
            <SelectedItemStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
            <HeaderTemplate>
            <table cellspacing="1" cellpadding="1" border="1">
            <tr>
            <td width="130">学校名称</td>
            <td width="150">学校省份</td>
            <td width="120">所在城市</td>
            <td width="150">学校类型</td>
            <td width="120">留言</td>
             </tr>
             </table>
            </HeaderTemplate>
            <ItemTemplate>
            <table cellpadding="1" cellspacing="1" border="1">
            <tr>
            <td width="130"><%#Eval("u_sname") %></td>
             <td width="150"><%#Eval("s_province") %></td> 
             <td width="120"><%#Eval("s_city") %> </td>
            <td width="150"> <%#Eval("s_type") %></td>
            <td width="120"><asp:LinkButton ID="LinkButton1" PostBackUrl="~/board.aspx?name=武汉工业学院" runat="server">去留言</asp:LinkButton></td>
           
            
            </table>
            
            </ItemTemplate>
           <FooterStyle ForeColor="Black" BackColor="#C6C282" />
           <HeaderStyle Font-Bold="True" ForeColor="#E7E7bb" BackColor="#2a4ede" />
           </asp:DataList>
           <center><h3>没有你要找的学校吗?</h3>
              <asp:HyperLink ID="HyperLink1"  NavigateUrl="~/regi_school.aspx" runat="server">注册</asp:HyperLink></center>
        </div>
    </form>
</body>
</html>
这是进入留言板的cs代码
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if(!IsPostBack)
        {
            SetBind();
            string u_sname;
            u_sname = Request["u_sname"]; 
        }
    }
    private void SetBind()
    {
        SqlConnection conn = new SqlConnection("Server=localhost;database=students;user=sa;pwd=");
       
        string str = "select * from school";
        SqlDataAdapter da = new SqlDataAdapter(str, conn);
        DataSet ds = new DataSet();
        da.Fill(ds, "school");
        DataTable dt = ds.Tables["school"];
        DataList1.DataSource = dt;
        DataList1.DataBind();
    }
}
我想法是,当我在某学校,如武汉大学这一行里点击“去留言”,然后返回可以武汉大学的名字这个参数,
然后根据SQL语句"select * from message where u_sname=(武汉大学)"显示出武汉大学留言板的内容,但那个武汉大学的名字总是传不过来
总是失败。
总的来说,就是两个页面间的参数传递不了。..好心的大哥们帮忙看下吧。..