Right click on the views\contact folder and add a new Windows Form. Name the form as SaveView. Make sure that the view inherits from the BaseView class provided by the koossery.MVCwin framework.
Adds a new data sources that points to the SaveViewData class.
The result view should look like the figure below:

Figure 6: Save contact View

The purpose of the label2 is to display error messages.

The next step is to override the BindDataToView method in order to initialize binding sources. The listing 1 shows the contain of the SaveView code-behind:

public partial class SaveView : BaseView
        public SaveView()

        public override void BindDataToView()
            //Retrieving the SaveViewData
            SaveViewData saveView = this.GetSessionData(typeof(SaveViewData).Name) as SaveViewData;

            //Initializing Data Source
            contactBindingSource.DataSource = saveView.Contact;

Edit the Click event of the Save button and write the logic to invoke the Save action of the SaveController as shown the listing 2:
private void btSave_Click(object sender, EventArgs e)
 //Invoke a specific action
 this.InvokeController(typeof(SaveController).Name, ApplicationData. SaveAction);

No data transfert is needed, everything is setted via DataBinding! Whenever the Save button is clicked, the action SaveAction of SaveController is invoked.

Last edited Jun 22, 2009 at 10:25 AM by koossery, version 2


No comments yet.