Formview on updating

Using strongly typed presentation layer templates is not the only thing that model binding is good for. NET MVC we know how convenient it is when model binders are also able to update our objects when they are modified.

In this posting I will show you how to use strongly typed Form View to save data that user modified.

the business object) since it's null in the On Item Inserting and On Item Updating events.

formview on updating-18

Update mechanism for strongly typed controls is similar to select one.

We have to define method that is called when control wants to save data.

POST) if form.is_valid(): self.send_mail(form.cleaned_data) form = Contact Form() return render(request, 'contact-us.html', ) return render(request, 'contact-us.html', ) def send_mail(self, valid_data): # Send mail logic print(valid_data) pass With proper urlpattern, you should be able to see the contact us form.

Submitting a valid form should be printing the valid data.

In my previous posting I introduced how to use strongly typed controls and how they select data.

Here is the product class we used I previous posting.Data Item property in the On Data Binding event so that I can fill a dropdownlist with the correct value by casting the enum type to an int.However,when trying to get the data OUT of the control into the business object I can't seem to get access to the Data Item (i.e.Here's what I did: protected void Form View1_Item Updating(object sender, Form View Update Event Args e) For some reason, ASP.NET seems to automatically cast the string in the Enum Type Property to Enum Type before putting it in the property.When they lodge a complaint, an email is sent to admin with order number and name of user.