当然是用Request.QueryString了。
        if (Request.QueryString["id"] != null)
        {
            string Id = Request.QueryString["Id"].ToString();
        }

解决方案 »

  1.   

    用Session传值
    前一个页面内.cs中,Session["ID"] = ?;
    x.aspx.cs中, string id = Session["ID"].ToString();
    最好先在globle配制文件中声明Session["ID"]并赋null
      

  2.   

    用 Request了
    if(!string.IsNullOrEmpty(Request["id"]))
    {
       string   Id   =   Request["Id"]; 
    }
      

  3.   

    用Request.QueryString就可以了,不用session
      

  4.   

    我把 x.aspx.cs中写下如下代码,调用
            string strConnection = "server=local;uid=sa;pwd=sa;database=dbname";
            SqlConnection objConnection = new SqlConnection(strConnection);
            objConnection.Open();
            SqlCommand cmd = new SqlCommand("SELECT * FROM class where classID=Request.QueryString['Id']", objConnection);
            SqlDataReader dr = cmd.ExecuteReader();
            string strBody1 = null;
            string strBody2 = null;
            dr.Read()
            strBody1 += "" + dr["name"] + "";
            strBody1 += "" + dr["show"] + "";
            dr.Close();
            objConnection.Close();
            return strBody;请问这样写对吗?
    如果我要在aspx文件中分别显示出name和show,改怎么办呢?谢谢
      

  5.   

     private string id = null;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                id = Request.QueryString["id"];
                Response.Write(id);
            }
        }
      

  6.   


    public string GetStrBody()
    {
    string   strConnection   =   "server=local;uid=sa;pwd=sa;database=dbname"; 
                    SqlConnection   objConnection   =   new   SqlConnection(strConnection); 
                    objConnection.Open(); 
                    SqlCommand   cmd   =   new   SqlCommand("SELECT   *   FROM   class   where   classID=Request.QueryString['Id']",   objConnection); 
                    SqlDataReader   dr   =   cmd.ExecuteReader(); 
                    string   strBody1   =   null; 
                    string   strBody2   =   null; 
                    dr.Read() 
                    strBody1   +=   ""   +   dr["name"]   +   ""; 
                    strBody1   +=   ""   +   dr["show"]   +   ""; 
                    dr.Close(); 
                    objConnection.Close(); 
                    return   strBody; 
    }protected   void   Page_Load(object   sender,   EventArgs   e) 

                    if   (!IsPostBack) 
                    { 
                            string strBody=GetStrBody();
                            string[] arry = strBody.split('');
                            string name = arry[0];
                            string show = arry[1]; 
    this.TextBox1.Text = name;
    this.TextBox2.Text = show;                } 
    }
      

  7.   

    aspx.cs文件public partial class _1 : System.Web.UI.Page
    {
        public string GetStrBody()
          {
                    //链接数据库并打开读取
                    string   strBody1   =   null; 
                    string   strBody2   =   null; 
                    dr.Read() 
                    strBody1   +=   ""   +   dr["title"]   +   ""; 
                    strBody1   +=   ""   +   dr["content"]   +   ""; 
                    dr.Close(); 
                    objConnection.Close(); 
                    return   strBody; 
         }
        protected void Page_Load(object sender, EventArgs e)
        {
            if   (!IsPostBack) 
                    { 
                            string strBody=GetStrBody();
                            string[] arry = strBody.split('');
                            string name = arry[0];
                            string show = arry[1]; 
                            this.TextBox1.Text = name;
                            this.TextBox2.Text = show;                } 
        }}aspx文件    <form runat="server">
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
        </form>我运行了,一直提示“ 编译器错误信息: CS1011: Empty character literal”错误,在 string[] arry = strBody.split(''); 这一行,请问改怎么解决呢?