| MultiRow Windows Forms > Developer's Guide > Using MultiRow > Connecting to Database |
The MultiRow control connects to the database using ADO.NET in the same way as the standard .NET Framework controls. The following example uses database products and samples.
Register the SQL Server database in the project. This is independent of MultiRow.
Create the template for MultiRow and assign the fields to the table.



Place the GcMultiRow control on the form and assign the data source and template to the grid.




This completes assigning the data source and template to the grid. If you run the project, the datasource values will be read into the grid.

The CustomerID column values in the Orders table are same as the values of the CustomerID column in the Customers table. Use the values of this CustomerID column as the base and enumerate the values in the CompanyName column of the Customers table.
Imports GrapeCity.Win.MultiRow
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim myTemplate As Template1 = New Template1()
Dim comboBoxCell As ComboBoxCell = DirectCast(myTemplate.Row("comboBoxCell1"), ComboBoxCell)
comboBoxCell.DataSource = Me.customersBindingSource
comboBoxCell.DisplayMember = "CompanyName"
comboBoxCell.ValueMember = "CustomerID"
comboBoxCell.DataField = "CustomerID"
Me.ordersGcMultiRow.Template = myTemplate
' TODO: This code reads the data into 'northwindDataSet.Customers' table. Please move or delete as required.
Me.customersTableAdapter.Fill(Me.northwindDataSet.Customers)
' TODO: This code reads the data into 'northwindDataSet.Orders' table. Please move or delete as required.
Me.ordersTableAdapter.Fill(Me.northwindDataSet.Orders)
End Sub
|
using GrapeCity.Win.MultiRow;
private void Form1_Load(object sender, EventArgs e)
{
Template1 myTemplate = new Template1();
ComboBoxCell comboBoxCell = myTemplate.Row["comboBoxCell1"] as ComboBoxCell;
comboBoxCell.DataSource = this.customersBindingSource;
comboBoxCell.DisplayMember = "CompanyName";
comboBoxCell.ValueMember = "CustomerID";
comboBoxCell.DataField = "CustomerID";
this.ordersGcMultiRow.Template = myTemplate;
// TODO: This code reads the data into 'northwindDataSet.Customers' table. Please move or delete as required.
this.customersTableAdapter.Fill(this.northwindDataSet.Customers);
// TODO: This code reads the data into 'northwindDataSet.Orders' table. Please move or delete as required.
this.ordersTableAdapter.Fill(this.northwindDataSet.Orders);
}
|
If you run the project, you can verify that the CompanyName column values have been enumerated into the Customer cells.

You can also verify that changing this value will change the values in the CustomerID cells bound to the same column.
