Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > question about mvc pattern and databinding
 

question about mvc pattern and databinding

hi all

i'm trying to implement an mvc pattern in my winformsapp.

my problem is when i think about using data binding in my app. if the view can get and set the data from the model(when using databinding)then the pattern is not doing what it should.

my question:
can i do one way binding? and let the controler class manipulate the data?
how does mvc pattern fits with data binding?

thanks all

Elad_me  Thursday, July 16, 2009 12:23 PM

Hi Elad,

> if the view can get and set the data from the model(when using databinding)then the pattern is not doing what it should.

When using data binding in your application, it's the data binding engine that sets the changes back to the underlying data source. This doen't break the MVC pattern.

> how does mvc pattern fits with data binding?

Bind thecontols on your form to the underlyingdata source. When the user changesthe values in the bound controls,data binding engine will send the changes back to the underlying data sourceautomatically. Use the controller to call the Save method on the model to save changes back to database.

Hope this helps.


Please remember to mark the replies as answers if they help and unmark them if they provide no help. end us any feedback you have about the help from MSFT at fbmsdn@microsoft.com.
Linda Liu  Tuesday, July 21, 2009 8:49 AM

Hi Elad,

> if the view can get and set the data from the model(when using databinding)then the pattern is not doing what it should.

When using data binding in your application, it's the data binding engine that sets the changes back to the underlying data source. This doen't break the MVC pattern.

> how does mvc pattern fits with data binding?

Bind thecontols on your form to the underlyingdata source. When the user changesthe values in the bound controls,data binding engine will send the changes back to the underlying data sourceautomatically. Use the controller to call the Save method on the model to save changes back to database.

Hope this helps.


Please remember to mark the replies as answers if they help and unmark them if they provide no help. end us any feedback you have about the help from MSFT at fbmsdn@microsoft.com.
Linda Liu  Tuesday, July 21, 2009 8:49 AM

You can use google to search for other answers

Custom Search

More Threads

• get from bindingsource to dataset to xml
• ListView row header in vb.net
• [DataGridView]Rows[0].Visible = false throws a InvalidOperationException
• Different Colored Rows in DataGridView Control
• DataView.Find problem
• datagrid search
• Values not getting Updated in Database
• ActiveLinkColor of DataGridViewLinkCell is not persistent
• Add results of form into a MSQL DB
• internet explorer 7