This is a migrated thread and some comments may be shown as answers.

Transfer, and saving to database

2 Answers 151 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Derek
Top achievements
Rank 1
Derek asked on 21 Dec 2009, 02:06 PM
I am trying to configure a pair of listboxes to allow transfer. The user interface side works, but no changes are written to the database. Here's the scenario;

Three tables, Communications, Contacts, and CommunicationContacts. Each communication has zero or more contacts associated with it, defined as rows in the CommunicationContacts table. The CommunicationContacts table has three fields; primary key, CommunicationID and ContactID, with appropriate relational integrity. What I want to do is show two listboxes; one containing the names of the people who are selected (from the Contacts table, via a lookup), and a list of names of people who aren't selected. I have the logic of the queries, but what i want is when I add a name from the UNSELECTED to the SELECTED list, I want a row to be added to the CommunicationContacts table. Likewise when I remove a name from teh selected list, I want that row to be removed from the CommunicationContacts table.

I have the page set up and working using object data sources, with update and delete actions defined, the transfers are appearing properly, but no db changes are recorded.

Can anyone provide me with an example of a working page where two related listboxes are used and the changes are saved?

Thanks in advance.

2 Answers, 1 is accepted

Sort by
0
Schlurk
Top achievements
Rank 2
answered on 21 Dec 2009, 03:16 PM
This demo does shows and example of having two ListBoxes and saving changes to their sources. Since it uses AutomaticUpdates it might not be the best solution for you so you can always use the ListBox events and manually call the add/delete methods.
0
Genady Sergeev
Telerik team
answered on 21 Dec 2009, 05:52 PM
Hello Derek,

Schulurk is right, you may not use the AutoUpdate functionality for such a complicated scenario. What you can do, is to hook on the Insert/Deleted events of the RadListBox and call the respective Insert/Delete methods of your Data Access Layer.

Sincerely yours,
Genady Sergeev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
ListBox
Asked by
Derek
Top achievements
Rank 1
Answers by
Schlurk
Top achievements
Rank 2
Genady Sergeev
Telerik team
Share this question
or