当我不重新绑定时,Gridview 仍处于编辑模式,为什么?但是当我重新绑定gridview它成功退出eidt模式时,为什么?
代码:
protected void gvTest_EditCancel(Object sender, GridViewCancelEditEventArgs e)
{
gvTest.EditIndex = -1;
// connectToDb();
Response.Write("<br/>"+ "Editing cancelled");
}`
public void connectToDb()
{
SqlConnection sqlcon = new SqlConnection(constrng);
String com1 = "select * from login";
SqlCommand sqlcom = new SqlCommand(com1, sqlcon);
SqlDataAdapter sqlda = new SqlDataAdapter(sqlcom);
DataSet ds = new DataSet();
try
{
sqlcon.Open();
sqlda.Fill(ds);
gvTest.DataSource = ds;
gvTest.DataBind();
}
catch (Exception exc)
{
Response.Write(exc.ToString());
}
finally
{
sqlcon.Close();
}
}
但是当调用 ConnectToDb() 重新绑定时,它成功退出编辑模式,重新绑定与编辑或退出有什么关系?