If I have two listboxes, with a button between them, how do I update the Items of ListBox2 if ListBox2's items are databound?
<asp:ListBox runat="server" ID="ListBox1" DataSourceID="DataSource1"
DataTextField="Name" DataValueField="ID" SelectionMode="Multiple" />
<asp:Button runat="server" ID="addButton" onClick="addButton_Click" />
<asp:ListBox runat="server" ID="ListBox2" DataSourceID="DataSource2"
DataTextField="Name" DataValueField="ID" SelectionMode="Multiple" />
Also if I use the SelectionMode="Multiple", will I be able to Update the DataSource using an UpdateCommand that takes one item at a time?
EDIT:
Ok, to add some clarification:
- Both Listboxes are DataBound to unique data (SqlDataSource).
- I want to add items from ListBox1 to ListBox2 and vice versa, when a user clicks a button.
- I want to be able to add multiple items to the ListBox (presume that multiple selection is turned on)
- I want that to trigger an UpdateCommand on the DataSource.
So far the only way I'm able to accomplish this is by manually taking each item from the first listBox and adding it as a parameter to the DataSource's UpdateCommand and manually call the SqlDataSource.Update() method. This works, but it means that I either need to pass a delimited string for multiple selections or open multiple connections. What I'm looking for is a way to update the DataSource on the ListBox and once it's fully updated, then call the Bind/Update and persist the data back to the DB.