sly_Chandan
sly_Chandan

Reputation: 3515

FormView doesnt change to readonly mode after updating? Why?

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);
        }

It doesnt go in readonly mode after updating record.

Upvotes: 0

Views: 1848

Answers (1)

Brian Mains
Brian Mains

Reputation: 50728

After changing a mode, you have to rebind. So supply the data source and call DataBind().

HTH.

Upvotes: 1

Related Questions