Re: asp.net - Filling datagrid by using grid properties
Posted by: Peter Brawley
Date: December 28, 2006 09:50AM

See the MSDN2 tutorial on setting up master-detail DataGridViews. The methods are the same for MySQL as for MSSQL. Here is a bit of sample C# code that should translate to VB pretty easily.
// POPULATE
DataSet dsGrid = new DataSet();
bindSrcMaster = new BindingSource();
dataGridView1.DataSource = bindSrcMaster;
Populate( ref dsGrid, "name of master table" );
bindSrcMaster.DataSource = dsGrid;
bindSrcMaster.DataMember = "name of master table";
bindSrcDetail = new BindingSource();
dataGridView2.DataSource = bindSrcDetail;
Populate( ref dsGrid, "name of detail table" );

// INSTANTIATE RELATION
DataColumn parentColumn = "???";
DataColumn childColumn = "???"; 
dr = new DataRelation( sMasTbl + sDetTbl, parentColumn, childColumn );
dsGrid.Relations.Add( dr );

...

public int Populate( ref DataSet ds, string tbl ) {
  int rows = 0;
  MySqlDataAdapter da = new MySqlDataAdapter();
  try {
    rows = da.Fill( ds, tbl );
  }
  catch ( MySqlException ex ) {
    MessageBox( ex.Message );
  }
  finally { }
  return rows;
}

Options: ReplyQuote


Subject
Written By
Posted
Re: asp.net - Filling datagrid by using grid properties
December 28, 2006 09:50AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.