Home All Groups Group Topic Archive Search About

FormView DataBinding in Insert mode

Author
7 Nov 2005 3:16 PM
Anders Skoglund
Hi,

I'm using the FormView control in combination with an ObjectDataSource
control to handle insert and update operations. The ObjectDataSource control
has a DataObjectTypeName defined that stores the information for each field.
When entering Insert Mode I would like to Bind the FormView control to get
default values filled in automatically. The problem is that the FormView
Controls doesn't seem to be Bindable in Insert mode:

if (frvDetails.CurrentMode == FormViewMode.Insert)
{
    // Change Select method to Get a special instance of DataObjectTypeName
    ods.SelectMethod = "GetDefaultValues";
    // Remove the SelectParameter, since no key is necessary
    ods.SelectParameters.Clear();
    // Bind the FormView control
    frvDetails.DataBind();
}

The ObjectDataSource fetches the record (The Selected event returns an
Instance of type defined in DataObjectTypeName), but FormView never Binds to
the returned record. I manually changed the mode of the FormView control to
Edit, and then it worked as expected. There seems to be no way to make
DataBinding operations in insert-mode!?

Thanks in advance,
Anders

Author
30 Jun 2006 4:10 PM
mwangtx
Hi Anders,
I have the same problem as you had. I would like to know your answers if you have had figured it out.  If not, can you tell me how you change the current mode of the formview from insert to edit???
Thanks.


Anders Skoglund wrote:
Show quoteHide quote
> *Hi,
>
> I'm using the FormView control in combination with an > ObjectDataSource
> control to handle insert and update operations. The ObjectDataSource > control
> has a DataObjectTypeName defined that stores the information for each > field.
> When entering Insert Mode I would like to Bind the FormView control > to get
> default values filled in automatically. The problem is that the > FormView
> Controls doesn't seem to be Bindable in Insert mode:
>
> if (frvDetails.CurrentMode == FormViewMode.Insert)
> {
> // Change Select method to Get a special instance of > DataObjectTypeName
> ods.SelectMethod = "GetDefaultValues";
> // Remove the SelectParameter, since no key is necessary
> ods.SelectParameters.Clear();
> // Bind the FormView control
> frvDetails.DataBind();
> }
>
> The ObjectDataSource fetches the record (The Selected event returns > an
> Instance of type defined in DataObjectTypeName), but FormView never > Binds to
> the returned record. I manually changed the mode of the FormView > control to
> Edit, and then it worked as expected. There seems to be no way to > make
> DataBinding operations in insert-mode!?
>
> Thanks in advance,
> Anders * -- mwangtx ------------------------------------------------------------------------ Posted via http://www.codecomments.com ------------------------------------------------------------------------