这是更新事件updatecommand的源码,但是不知道为什么编辑完后点更新数据还是一样的,用断点调试,发现参数的值没有变化 
string ProductID=dtg1.DataKeys[e.Item.ItemIndex].ToString (); 
string newname=((TextBox)(e.Item .Cells [0].Controls [0])).Text ; 
string newon=((TextBox)(e.Item .Cells [2].Controls [0])).Text ; 
string str1="update Products set ProductName='"+newname+"',UnitsOnOrder='"+newon 
+"'where ProductID="+ProductID;

解决方案 »

  1.   

    string str1="update Products set ProductName='"+newname+"',UnitsOnOrder='"+newon 
    +"'where ProductID='"+ProductID+"';
      

  2.   

    忘了加引号,这个是正确的
    string str1="update Products set ProductName='"+newname+"',UnitsOnOrder='"+newon 
    +"'where ProductID='"+ProductID+"' ";
      

  3.   

    更新之后需要重新绑定DATAGRID
    查看有没有更新进去...
      

  4.   

    string str1="update Products set ProductName='"+newname+"',UnitsOnOrder='"+newon 
    +"'where ProductID='"+ProductID+"' ";
     不行啊,还有我也重新绑定了啊》