this.txtProgramName.DataBindings.Add("Text",this.dsTables.Programs,"Schools_Programs.Name"); this.txtProgramDesc.DataBindings.Add("Text",this.dsTables.Programs,"Schools_Programs.Description"); // - or this - this.txtProgramName.DataBindings.Add("Text",this.dsTables.Programs,"Name"); this.txtProgramDesc.DataBindings.Add("Text",this.dsTables.Programs,"Description");~~Bonnie
>// Fill typed data set >this.StandardFill("select * from schools",ref this.schoolsAdapter,this.dsTables,"Schools"); >this.CommandBuilderFill("select * from programs",ref this.programsAdapter,this.dsTables,"Programs"); >this.StandardFill("select * from contacts",ref this.contactsAdapter,this.dsTables,"Contacts"); >this.CommandBuilderFill("select * from programcontacts",ref this.programcontactsAdapter,this.dsTables,"ProgramContacts"); > >// Set up PrimaryKeys >this.dsTables.Schools.PrimaryKey = new DataColumn[] {this.dsTables.Schools.SchoolIDColumn}; >this.dsTables.Programs.PrimaryKey = new DataColumn[] {this.dsTables.Programs.ProgramIDColumn}; >this.dsTables.ProgramContacts.PrimaryKey = new DataColumn[] {this.dsTables.ProgramContacts.UniqueIDColumn}; >this.dsTables.Contacts.PrimaryKey = new DataColumn[] {this.dsTables.Contacts.ContactIDColumn}; > >// Create Relationship (Between SCHOOLS(p) and PROGRAMS(c)) >this.dsTables.Relations.Add("Schools_Programs", > this.dsTables.Schools.SchoolIDColumn, > this.dsTables.Programs.SchoolIDColumn, > true); > >// Create Relationship (Between PROGRAMS(p) and PROGRAMCONTACTS(c)) >this.dsTables.Relations.Add("Programs_ProgramContacts", > this.dsTables.Programs.ProgramIDColumn, > this.dsTables.ProgramContacts.ProgramIDColumn, > true); > >// Create Relationship (Between PROGRAMCONTACTS(p) and CONTACTS(c)) >this.dsTables.Relations.Add("ProgramContacts_Contacts", > this.dsTables.ProgramContacts.ContactIDColumn, > this.dsTables.Contacts.ContactIDColumn, > false); > >// Hide some columns so they don't show in grid. >this.dsTables.ProgramContacts.UniqueIDColumn.ColumnMapping = MappingType.Hidden; >this.dsTables.ProgramContacts.ProgramIDColumn.ColumnMapping = MappingType.Hidden; >this.dsTables.ProgramContacts.ContactIDColumn.ColumnMapping = MappingType.Hidden; > >// Add custom columns to PROGRAMCONTACTS to show in grid. >this.AddCustomColumn(this.dsTables.ProgramContacts,typeof(string),"First Name","MAX(Child.FirstName)"); >this.AddCustomColumn(this.dsTables.ProgramContacts,typeof(string),"Last Name","MAX(Child.LastName)"); >>
>// Since we cannot manage data binding for most controls at design >// time, we bind all data controls in this central location. > >this.txtSchoolName.DataBindings.Add("Text",this.dsTables.Schools,"Name"); >this.txtProgramName.DataBindings.Add("Text",this.dsTables.Schools,"Schools_Programs.Name"); >this.txtProgramDesc.DataBindings.Add("Text",this.dsTables.Schools,"Schools_Programs.Description"); > >this.grdContacts.SetDataBinding(this.dsTables.Schools,"Schools_Programs.Programs_ProgramContacts"); >this.grdPrograms.SetDataBinding(this.dsTables.Schools,"Schools_Programs"); >>