Binding to Data in Grid Rows
In addition to Grid.DataSource property that has become a common method of data binding in the grid, starting rom version 2.5.0 the grid provides a new API to bind either the grid or individual rows to data sources.
Row.DataSource = 'your data source';
The bound data source may implement IList or IBindingList interfaces. If the bound data source implements IBindingList interface, the grid subscribes to notifications of this ata collection and enables automated thread-safe management of content changes.
public class Basket
{
private readonly BindingList<Order> _orders = new BindingList<Order>();
public IList<Order> Orders
{
get { return _orders; }
}
}
public void InitializeGrid(Grid grid, IList<Basket> baskets)
{
grid.DataSource = baskets;
foreach(Basket basket in baskets)
{
Row row = grid.DataObjects.FindFirstRow(basket);
if(row != null)
{
row.DataSource = basket.Orders;
}
}
}
Back to .Net Grid Features