刚学asp的,这个是留言板的一个页面,获取留言者id的功能,不知道哪里有错,请指教
protected void replyButton_Click(object sender, EventArgs e)
    {
        int id = Convert.ToInt32(Request.QueryString["CommandArgument"]);
        string id = Request.QueryString["Id"];
                Response.Write(id.ToString());
        //string strreply = this.replyBox.Text;
        //SqlConnection con = dbconn.connection();
        //con.Open();
        //string query = "update userInfo set reply='" + strreply + "' where Id=";
        //string queryid = query + "'" + id + "'";
        //SqlCommand cmd = new SqlCommand(queryid, con);
        //if ((cmd.ExecuteNonQuery()) > 0)
        //{        //    Response.Redirect("~/Default.aspx");
        //}
        //else
        //{
        //    Response.Write("您的回复失败");        //}
        //con.Close();    }
}

解决方案 »

  1.   

    刚学asp的,这个是留言板的一个页面,获取留言者id的功能,不知道哪里有错,请指教 应该是这样的 ,
    protected void replyButton_Click(object sender, EventArgs e) 
        { 
            int id = Convert.ToInt32(Request.QueryString["CommandArgument"]); 
            //string id = Request.QueryString["Id"]; 
                    Response.Write(id.ToString()); 
            //string strreply = this.replyBox.Text; 
            //SqlConnection con = dbconn.connection(); 
            //con.Open(); 
            //string query = "update userInfo set reply='" + strreply + "' where Id="; 
            //string queryid = query + "'" + id + "'"; 
            //SqlCommand cmd = new SqlCommand(queryid, con); 
            //if ((cmd.ExecuteNonQuery()) > 0) 
            //{         //    Response.Redirect("~/Default.aspx"); 
            //} 
            //else 
            //{ 
            //    Response.Write("您的回复失败");         //} 
            //con.Close();     } 
    }
      

  2.   

    看看前面的那个页面的代码吧
    看跳转时是否有传CommandArgument这个参数过来