Groups | Blog | Home
all groups > asp.net webcontrols > november 2005 >

asp.net webcontrols : FormView DataBinding in Insert mode


Anders Skoglund
11/7/2005 12:00:00 AM
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
6/30/2006 11:10:26 AM

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.


[quoted text, click to view]



--
mwangtx
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------
AddThis Social Bookmark Button