我用文本框读出了数据库数据.然后通过删掉文本框的信息.重新填写数据,点提交进行修改数据库内容..这样能实现吧..??
但我这样做修改不了啊..一点提交,文本框又变回原来的数据了!!怎么办啊?

解决方案 »

  1.   


    ... Page_load...
      {
          if(!IsPostBack)
              {
                  //绑定
               }
      }
      

  2.   

    我写好了UPDATE的存储过程..用查询分析器测试过完全正确.我现在想把已经读出在文本框中的数据.通过从新填写.然后用那个存储过程修改数据..但总是没修改成功..!! 
     protected void Button2_Click(object sender, EventArgs e) 
        {   int a; 
            int b; 
            int c; 
            if (this.CheckBox1.Checked) 
                a = 1; 
            else 
                a = 0; 
            if (this.CheckBox2.Checked) 
                b = 1; 
            else 
                b = 0; 
            if (this.CheckBox3.Checked) 
                c = 1; 
            else 
                c = 0; 
         
            string id = Request.QueryString["id"].ToString(); 
            int messageid = Convert.ToInt32(id); 
            ClassLibrary.managepd clm = new ClassLibrary.managepd(); 
            try 
            { 
               clm.updatebook(this.TextBox1.Text, this.TextBox2.Text, this.TextBox3.Text,                this.TextBox4.Text, this.TextBox5.Text, this.TextBox6.Text, this.TextBox7.Text, this.TextBox8.Text, a, b, c, messageid);//调用类库中的UPDATEBOOK方法(就是用存储过程的方法)            Response.Write(" <script language='javascript'>alert('修改成功!'); </script>"); 
            } 
            catch (Exception ) 
            { 
                Response.Write(" <script language='javascript'>alert('修改失败!'); </script>"); 
            } 
        } 
    `````````````````````````````````````````````````````````````````````````````````````````````````````` UPDATEBOOK方法 
     public void updatebook(string bookname, string author, string publish, string publishdate, string isbn, string  oldprice, string nowprice,string zaiyao,int tuijian,int isonframe,int ischeap,int id) 
            { 
                SqlConnection conn = new SqlConnection(common.Class1.con); 
                conn.Open(); 
                SqlCommand com = new SqlCommand(common.Class1.updateb, conn); 
                com.CommandType = CommandType.StoredProcedure; 
                com.Parameters.Add("@bookname", SqlDbType.VarChar, 50).Value = bookname; 
                com.Parameters.Add("@author", SqlDbType.VarChar, 50).Value = author; 
                com.Parameters.Add("@publish", SqlDbType.VarChar, 200).Value = publish; 
                com.Parameters.Add("@publishdate", SqlDbType.VarChar,50).Value = publishdate; 
                com.Parameters.Add("@isbn", SqlDbType.VarChar, 50).Value = isbn; 
                com.Parameters.Add("@oldprice", SqlDbType.VarChar, 50).Value = oldprice; 
                com.Parameters.Add("@nowprice", SqlDbType.VarChar, 50).Value = nowprice; 
                com.Parameters.Add("@zaiyao", SqlDbType.VarChar, 200).Value = zaiyao; 
                com.Parameters.Add("@tuijian", SqlDbType.Int,4 ).Value = tuijian; 
                com.Parameters.Add("@isonframe", SqlDbType.Int, 4).Value = isonframe; 
                com.Parameters.Add("@ischeap", SqlDbType.Int,4).Value = ischeap; 
                com.Parameters.Add("@id", SqlDbType.Int).Value = id; 
                SqlDataAdapter da = new SqlDataAdapter(); 
                da.UpdateCommand = com; 
                com.ExecuteNonQuery(); 
                conn.Close(); 
            
            }
      

  3.   

    miaoyu04,谢谢喇!!唉..我菜鸟~~~加了!ISPOSTBACK就行了