Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to Undo changes in a table.
Message
From
08/10/2004 13:03:16
 
General information
Forum:
ASP.NET
Category:
ADO.NET
Miscellaneous
Thread ID:
00949939
Message ID:
00949961
Views:
9
Paul,

Just a guess, but have you tried binding to the Programs table instead? I'm not sure which would be the correct syntax (I haven't messed around with Relations, so I may be way off base):
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

>All:
>
>I have four tables with three relations setup.
>
>
>// 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)");
>
>
>Here is how I'm binding the tables/relations to my controls:
>
>
>// 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");
>
>
>My question is how do I Undo my changes when the user makes changes to:
>
>this.txtProgramName
>this.txtProgramDesc
>
>I've tried this.dsTables.Programs.RejectChanges() but it doesn't do anythng.
>
>--Paul
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform