Binding mmDataList to Strongly Typed Data

To data bind an mmDataList control to strongly typed data follow the stops outlined in this topic.

  1. Create a business object method that retrieves data you want to bind to the mmDataList.

    For example, in C#:

    /// <summary>
    /// Returns a strongly typed list of OrdersEntity objects for the specified customer
    /// </summary>
    /// <param name="customerID">Customer ID</param>
    /// <returns>Strongly Typed List of OrdersEntity objects</returns>
    public mmBindingList<OrdersEntity> GetUnfulfilledOrders()
    {
    	return this.GetEntityList("GetUnfulfilledOrders");
    }

    And in VB .NET:

    ''' <summary>
    ''' Returns a strongly typed list of OrdersEntity objects for the specified customer
    ''' </summary>
    ''' <param name="customerID">Customer ID</param>
    ''' <returns>Strongly Typed List of OrdersEntity objects</returns>
    Public Function GetUnfulfilledOrders() As mmBindingList(Of OrdersEntity)
        Return Me.GetEntityList("GetUnfulfilledOrders")
    End Function

  2. Register the business object in the web form's Load handler then call the business object method that retrieves the data

    For example, in C#:

    public partial class _Default : mmBusinessWebPage
    {
    	protected Orders Orders;
    
    	/// <summary>
    	/// Page Load handler
    	/// </summary>
    	/// <param name="sender">Event source</param>
    	/// <param name="e">Event args</param>
    	protected void Page_Load(object sender, EventArgs e)
    	{
    		this.Orders = (Orders)this.RegisterBizObj(new Orders());
    		if (!IsPostBack)
    		{
    			this.Orders.GetUnfulfilledOrders();
    		}
    	}
    }

    And in VB .NET:

    Public Class _Default
       Inherits mmBusinessWebPage
    
    	Protected Orders As Orders
       
    	''' <summary>
    	''' Page Load handler
    	''' </summary>
    	''' <param name="sender">Event source</param>
    	''' <param name="e">Event args</param>
    	Protected Sub Page_Load(sender As Object, e As EventArgs)
      		Me.Orders = CType(Me.RegisterBizObj(New Orders()), Orders)
    		If Not IsPostBack Then
    			Me.Orders.GetUnfulfilledOrders()
    		End If
    	End Sub 
    
    End Class

  3. Display the web form in design mode, then drag and drop the mmDataList control on your web form. In the popup menu select Auto Format...:

  4. In the Auto Format dialog, select a format for your mmDataList, then click OK:

  5. In the popup menu's Choose Data Source combo box, select <New data source...>:

    In the following steps you will create a temporary data source for the sole purpose of hooking into the Visual Studio UI generation features. In a later step you will delete the data source.

  6. In the Data Source Configuration Wizard, select Object and click OK:

  7. In the Choose Your business object combo box, choose the business object you specified in the previous steps, then click Next:

  8. In the Define Data Methods page of the wizard, select the business object method that returns the list of items to be displayed in the DataList then click Finish:

    This adds controls to the mmDataList for all strongly typed properties in your Business Entity object:

  9. Click the DataList's smart tag again and select Edit Templates:

    The default template is ItemTemplate:

    You can change the template in a variety of ways, for example, you can delete unwanted controls (such as HasValues) and resize the template.

  10. When you are finished editing the template, click the DataList's smart tag and select End Template Editing:

  11. Click the mmDataList's smart tag to display its popup menu. In the Choose Data Source combo box, select (None):

  12. In the Reset Templates dialog, click No. This clears the object data source settings, but doees not remove the template Visual Studio automatically created for you:

  13. With the mmDataList control selected, go to the Properties Window select the BindingSource property, click its associated ellipses button [...] and select the business object you registered in the web form.

  14. Scroll to the bottom of the mmDataList control, right-click the ObjectDataSource control and select Delete from the shortcut menu:

You should now be able to run your web page and see the mmDataList control filled with the data you specified:



© (c) 2026 Oak Leaf Enterprises, Inc., 1996-2026 • Updated: 02/17/08
Comment or report problem with topic