我想编辑GridView
而不涉及数据库
protected void myGridView_RowUpdating(object sender,GridViewUpdateEventArgs e)
{
string reg = (myGridView.DataKeys[e.RowIndex].Value.ToString());
GridViewRow row = (GridViewRow)myGridView.Rows[e.RowIndex];
TextBox name = (TextBox)row.Cells[1].Controls[0];
TextBox email = (TextBox)row.Cells[2].Controls[0];
myGridView.EditIndex = -1;
BindGird();
}
这是我的bindgrid功能:
protected void BindGird()
{
DataTable dt = (DataTable)Session["myCart"];
this.myGridView.DataSource = dt; this.myGridView.DataBind();
}
这是行编辑事件
protected void myGridView_RowEditing(object sender, GridViewEditEventArgs e)
{
myGridView.EditIndex = e.NewEditIndex; BindGird();
}