Last post Mar 16, 2007 05:38 AM by finite-in
Aug 30, 2006 07:54 AM|lukan|LINK
In a FormView, when we click "New", it enters the "Insert mode", how can I make my FormView be already in this "insert mode" when I load the page?
I can't find the functions so far.
Can anyone help me?
Thank you very much.
Aug 30, 2006 11:12 AM|Dave Sussman|LINK
The FormView has a DefaultMode property:
<asp:FormView DefaultMode=Insert" ...
Aug 31, 2006 05:02 AM|lukan|LINK
But when I try to programatically set it,
protected void Page_Load(object sender, EventArgs e)
CS0103: The name 'Insert' does not exist in the current context"
How to solve this?
Aug 31, 2006 05:24 AM|alvinz_c|LINK
Hi, You can try FormView.ChangeMode(FormViewMode.Insert)
Hope this helps..
Aug 31, 2006 06:01 AM|lukan|LINK
Thank you very much! It works!
Aug 31, 2006 08:32 AM|Dave Sussman|LINK
When set in code you have to use the FormViewMode enumeration:
FormViewMember.DefaultMode = FormViewMode.Insert;
But as you've already found out, ChangeMode works just as well.
Jan 24, 2007 10:24 PM|FrankBollard|LINK
Mar 05, 2007 05:26 PM|Pocketman|LINK
I have a FormView used for editing an inserting new records. Using a text box and button, the user can search for the record to be edited. It works as expected, but has a shortcoming. If the search returns no records, the form doesn't appear and the user
doesn't receive the "Edit Delete New" options. Setting the default to "Insert" negates the search function.
I think the best approach would be to create a button control that would bring up an insert form. I've tried a few suggestions from this thread, yet don't get the desired results. What code would I use behind the button to bring up the insert form?
Mar 05, 2007 05:27 PM|Pocketman|LINK
I think the best approach would be to create a button control that would bring up an insert form. I've tried a few suggestions from this forum, yet don't get the desired results. What code would I use behind the button to bring up the insert form?
Mar 05, 2007 07:19 PM|Pocketman|LINK
With help from a few other postings, was able to figure out a solution. [:)]
Mar 16, 2007 05:38 AM|finite-in|LINK
Has anybody noticed that if you have a FormView with a DefaultMode="ReadOnly", then programmatically change the mode to either Edit or Insert, then the corresponding update buttons will not submit their command?
For example, in Insert mode, the insert button will submit but not trigger the OnItemInserting event.
Programmatically changing the DefaultMode to match the ChangeMode parameter has no effect. However, if one changes the DefaultMode in the FormView itself to "Insert", the insert commands will work. Same thing for "Edit". It seems like the command buttons
work only for the mode specified in the DefaultMode and programmatically changing the mode will correctly display the view and buttons, but will not correctly submit the appropriate commands.
I have not been able to figure out this problem. I am doing this when the page loads based on a parameter from another page (not as a result of a postback). I have been all over looking for any mention of this problem and this is the closest I've found.