Change Mode Of DetailsView FormView From Default Mode set to Insert If you have a DetailsView or FormView on your aspx page and set it's Default mode to Insert than after record insertion it's mode can be changed to default mode by writing following code in ItemInserted Event
protected void DetailsView1_ItemInserted (object sender, DetailsViewInsertedEventArgs e) { DetailsView1.ChangeMode(DetailsViewMode.ReadOnly); }
But this code doesn't work , reason being DefaultMode is applied after the call to change the mode , to get it working or to get the mode changed, u need to write code like this
protected void DetailsView1_ItemInserted
(object sender, DetailsViewInsertedEventArgs e)
{
e.KeepInInsertMode = true;
DetailsView1.ChangeMode(DetailsViewMode.ReadOnly);
}
Now mode will be changed , similarly you can change the mode to edit.
If you like this post than join us or share
5 comments:
Nice info
Thanks! This is exactly what I've been looking for.
Verry NICE Blog,... i wait you at my BLOG ...
Worked perfect. Thanks a lot.
This comment has been removed by a blog administrator.
Post a Comment