This project is read-only.

ViewData represents Front End Datas. Each view has its underlying ViewData. ViewData contains the data wich can be displayed through the associated view. These datas are displayed to the view using DataBinding.

Binding sources can be initialized using the BaseView BindDataToView method. The listing 1 shows how an initialization is made.

public partial class LoginView : BaseView
{
   public override void BindDataToView()
   {            
      LoginViewData loginViewData = this.GetSessionData(typeof(LoginViewData).Name) as LoginViewData;
      bsLoginViewData.DataSource = loginViewData;
     }
}

Creating ViewData

A viewData is a simple .NET Class that extends koossery.MVCwin framework provides an AbstractBaseData. This base class inherits from BindableBase and implements IDataErrorInfo interface. The IDataErrorInfo interface lets an object store and expose error information that can be used by bound controls to notify the user when errors were encountered while using the object. It exposes a top-level error message for the object as a whole, as well as an indexer that can expose per-property error messages. Controls such as the DataGridView can use this information to expose in-place error indications and messages to the user. By implementing this interface on your custom data objects, and storing error information at the object or property level that you expose through these interface properties, you enable data-bound controls to provide a richer error-handling experience to the user.

The BindableBase class implements the INotifyPropetyChanged interface, so that all Front End datas supports bidirectional databinding. The INotifyPropertyChanged interface lets an object notify its container any time a property on the object changes.

The BindableBase class inherits from the CloneableBase class which allows all Front End datas to be cloneable.

Creating a ViewData consists in adding a simple .NET class which inherits from the AbstractBaseData class

New_ViewData.PNG

The final class is shown in the listing 2

using System;
using System.Collections.Generic;
using System.Text;
using Koossery.MVCwin.Data;

namespace Koossery.MVCwin.Tuto.App_Code.data.session.connexion
{
    public class CustomViewData : AbstractBaseData
    {

    }
}

NB : There is not need for your ViewData to have the ViewData suffix.

Last edited Jun 19, 2009 at 5:56 PM by mohamadou, version 5

Comments

No comments yet.