日期:2014-05-19  浏览次数:20412 次

datagrid 的问题,急!急!急!
private   void   DataGrid1_UpdateCommand(object   source,   System.Web.UI.WebControls.DataGridCommandEventArgs   e)
{
string   strid   =   DataGrid1.DataKeys[e.Item.ItemIndex].ToString();     //更新,修改


string   strjinjia   =   ((TextBox)e.Item.Cells[3].Controls[0]).Text;
string   strchushou   =   ((TextBox)e.Item.Cells[4].Controls[0]).Text;
string   strduihuan=((TextBox)e.Item.Cells[5].Controls[0]).Text;


string   strSql   =   "update   H_Background   set   Stock_Price=@jinjia,Now_Price=@chushou,Par_value=@duihua   where   Background_id=@id ";


SqlParameter   param1   =   new   SqlParameter( "@id ",SqlDbType.Int);
param1.Value=strid;


SqlParameter   param2   =   new   SqlParameter( "@jinjia ",SqlDbType.Money);
param2.Value=strjinjia;


SqlParameter   param3   =   new   SqlParameter( "@chushou ",SqlDbType.Money);
param3.Value=strchushou;


SqlParameter   param4=   new   SqlParameter( "@duihua ",SqlDbType.Money);
param4.Value=strduihuan;

int   ws=DataBase.WSQL.ExecuteSql(strSql,param1,param2,param3,param4);
if(ws!=0)
{
DataBase.DHK.Show(this, "更新成功! ");
}
DataGrid1.EditItemIndex   =   -1;
DataBind();
}

我想获取编辑文本的值,但是这样获取的还是原来的值。

------解决方案--------------------
是不是在Page_load时重新绑定了?有没有if(!this.IsPostBack)
------解决方案--------------------
应该是差个ispostback