既然是varcharstring bianhao = (TextBox)e.Item.Cells[2].Controls[0]).Text;
这样就OK了,
Int32.Parse是把它显式转为int类型

解决方案 »

  1.   

    更新的时候这一句有错误:
    string bookname =e.Item.Cell[1].Text;
    string bianhao = (TextBox)e.Item.Cells[2].Controls[0]).Text;
    string cbs= (TextBox)e.Item.Cells[2].Controls[0]).Text;string jieshao= (TextBox)e.Item.Cells[2].Controls[0]).Text;
    string strUpdate ="Update book Set 
    bianhao="+bianhao+", cbs="+cbs+",jieshao="+jieshao+" where bookname='"+bookname+"'"; 常数中有换行符源错误: 行 55: string jieshao= (TextBox)e.Item.Cells[2].Controls[0]).Text;
    行 56: 
    行 57: string strUpdate ="Update book Set 
    行 58: bianhao="+bianhao+", cbs="+cbs+",jieshao="+jieshao+" where bookname='"+bookname+"'";
    行 59: SqlCommand myComm=new SqlCommand(strUpdate,myComm);
     
      

  2.   

    行 57: string strUpdate ="Update book Set 
    行 58: bianhao="+bianhao+", cbs="+cbs+",jieshao="+jieshao+" where bookname='"+bookname+"'";应该为:    string strUpdate ="Update book Set bianhao ='" + bianhao + "',cbs ='" +
                   cbs + "',jieshao = '" + jieshao + "' where bookname='" + bookname + "'";
      

  3.   

    string bianhao = (TextBox)e.Item.Cells[2].Controls[0].Text;上面多了一个),去掉就OK了
      

  4.   

    还是不行~
    string bookname =e.Item.Cell[1].Text;
    string bianhao = (TextBox)e.Item.Cells[2].Controls[0].Text;
         string cbs= (TextBox)e.Item.Cells[2].Controls[0].Text;
     string jieshao= (TextBox)e.Item.Cells[2].Controls[0].Text;string strUpdate ="Update book Set 
    bianhao='"+bianhao+"', cbs='"+cbs+"',jieshao='"+jieshao+"' where bookname='"+bookname+"'";
    SqlCommand myComm=new SqlCommand(strUpdate,myComm);行 54:  string jieshao= (TextBox)e.Item.Cells[2].Controls[0].Text;
    行 55: 
    行 56: string strUpdate ="Update book Set 
    行 57: bianhao='"+bianhao+"', cbs='"+cbs+"',jieshao='"+jieshao+"' where bookname='"+bookname+"'";
    行 58: SqlCommand myComm=new SqlCommand(strUpdate,myComm);
      

  5.   

    看看你的字段类型,我看是sql语句的问题
      

  6.   

    都是 varchar  除了id 是int id 用的标识
      

  7.   

    行 56: string strUpdate ="Update book Set
    行 57: bianhao='"+bianhao+"', cbs='"+cbs+"',jieshao='"+jieshao+"' where bookname='"+bookname+"'";上面两行没有连接符,改一下或是把它放在一行吧:
    行 56: string strUpdate ="Update book Set "+
    行 57: "bianhao='"+bianhao+"', cbs='"+cbs+"',jieshao='"+jieshao+"' where bookname='"+bookname+"'";