不知你想看到的是不是这样的code(不过这些MSDN里面都有指导的)private void DataGrid1_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
this.DataGrid1.EditItemIndex = e.Item.ItemIndex;
this.BindData();
}
private void DataGrid1_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
// Hashtable ht = new Hashtable();
DataTable dta = this.ds.Tables[this.tableIndex];
// string key = this.DataGrid1.DataKeys[e.Item.ItemIndex].ToString();// store the primary key in the dataset
// but why do not store the key from directely DB?
TextBox tb;
// object[] oa = new object[dta.Rows[0].ItemArray.Length]; for(int i=1;i<e.Item.Cells.Count;i++)
{
tb = (TextBox)e.Item.Cells[i].Controls[0];
dta.Rows[e.Item.ItemIndex][i-1] = this.Transmit(tb.Text,dta.Columns[i-1].DataType);
// ht.Add(((DataGrid)source).Columns[i].HeaderText,tb.Text);// why the datagrid`s column number is only 2?
// oa[i-2] = tb.Text;
}
this.DataGrid1.EditItemIndex = -1;
// Updata the dataset to DB // bind again;
BindData();
}