更新后,FormView不会更改为只读模式?为什么?

时间:2011-07-12 16:39:32

标签: asp.net

protected void FormView1_ModeChanging(object sender, FormViewModeEventArgs e)
        {
            this.FormView1.ChangeMode(e.NewMode);
        }
protected void FormView1_ItemUpdating(object sender, FormViewUpdateEventArgs e)
        {
            int id = int.Parse(e.CommandArgument.ToString());
            TextBox text1 = (TextBox)FormView1.FindControl("txtNameEdit");
            TextBox text2 = (TextBox)FormView1.FindControl("txtStatusEdit");
            comp.UpdateRecord(text1.Text, int.Parse(text2.Text), id);
            ds = BindGridView();
            GridView1.DataSource = ds;
            GridView1.DataBind();
        }

        protected void FormView1_ItemUpdated(object sender, FormViewUpdatedEventArgs e)
        {
            FormView1.ChangeMode(FormViewMode.ReadOnly);
        }

更新记录后,它不会进入只读模式。

1 个答案:

答案 0 :(得分:1)

更改模式后,您必须重新绑定。所以提供数据源并调用DataBind()。

HTH。