Izbornik Zatvoriti

C# .NET – Definicija Master – Detail veze dve tabele

Skraćena veza: https://pedja.supurovic.net/veza/5353

Podešavanje prikaza master/detail vezu dve tabele u .NET nije baš očigledno nekome ko je navikao na neku drugu platformu. Zato, evo kratkog primera kako to podesiti :

//
//
// kreiraj dataset
ds = new DataSet();

//
//
// kreiraj master tabelu
DataTable dtMaster = new DataTable();
dtMaster.Columns.Add ("id_master", typeof (string));
dtMaster.Columns.Add ("description", typeof (string));

//
//
// napuni je podacima
dtMaster.Rows.Add ("1", "prvi");
dtMaster.Rows.Add ("2", "drugi");
dtMaster.Rows.Add ("3", "treci");
dtMaster.Rows.Add ("4", "cetvrti");

//
//
// podesi primarni kljuc
DataColumn[] MasterPrimaryKeyColumns = new DataColumn[1];
MasterPrimaryKeyColumns[0] = dtMaster.Columns["id_master"];
dtMaster.PrimaryKey = MasterPrimaryKeyColumns;

//
//
// dodaj tabelu u DataSet
ds.Tables.Add
 […]
[ ... vidi ceo članak ... ]