Binding mmGridView to Strongly Typed Data

To data bind an mmGridView 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 mmGridView.

    For example, in C#:

    /// <summary>
    /// Get all employees
    /// </summary>
    /// <returns>Employee DataTable</returns>
    public EmployeeDataSet.EmployeesDataTable GetAllEmployees()
    {
    	this.GetDataSet("SELECT * FROM Employees");
    	return this.EmployeeTable;	
    }

    And in VB .NET:

    ''' <summary>
    ''' Get all employees
    ''' </summary>
    ''' <returns>Employee DataTable</returns>
    Public Function GetAllEmployees() As EmployeeDataSet.EmployeesDataTable
       Me.GetDataSet("SELECT * FROM Employees")
       Return Me.EmployeeTable
    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 Employee oEmployee;
    
    	/// <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.oEmployee = (Employee)this.RegisterBizObj(new Employee());
    		if (!IsPostBack)
    		{
    			this.oEmployee.GetAllEmployees();
    		}
    	}
    }

    And in VB .NET:

    Public Class _Default
       Inherits mmBusinessWebPage
    
    	Protected oEmployee As Employee
       
    	''' <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.oEmployee = CType(Me.RegisterBizObj(New Employee()), Employee)
    		If Not IsPostBack Then
    			Me.oEmployee.GetAllEmployees()
    		End If
    	End Sub 
    
    End Class

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

  4. In the Auto Format dialog, select a format for your mmGridView, 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 select the appropriate business object, then click Next:

  8. In the Define Data Methods page of the wizard, select the method on your business object that returns the strongly typed list:

    This adds controls to the mmGridView for all strongly typed properties in your strongly typed list:

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

  10. In the dialog, click No. This clears the object data source settings, but does not remove the columns Visual Studio automatically created for you:

  11. If you like the default columns Visual Studio created for you, skip to the next step. Otherwise, click the mmGridView's smart tag again to display the popup menu, then select Edit Columns:

  12. In the Fields dialog you can remove or reorder columns as well as change the header text and other column properties:

    When you're finished editing the columns, click OK to close the dialog.

  13. With the mmGridView 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. If you are binding to the business object's default DataTable you can skip to the next step. If you are binding to a different DataTable, set the BindingSourceMember to the name of that DataTable. If you are binding to a DataView, set the BindingSourceMember property to the name of the DataTable.DataView you are binding to. For details, see Data Binding Web Forms Data Grids.

  15. Right-click the ObjectDataSource control at the bottom of the mmGridView control and select Delete from the shortcut menu:

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



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