G
Guest
I'm going crazy with this. I just added two Listboxes (lbxSource->multiple
selection and lbxDestination -> single selection).
Then:
a) button "Load":
ListItem l0 = new ListItem("01");
lbxDestination.Items.Add(l0); //1st goes to Destination Box
ListItem l1 = new ListItem("02");
lbxSource.Items.Add(l1);
ListItem l2 = new ListItem("03");
lbxSource.Items.Add(l2);
ListItem l3 = new ListItem("04");
lbxSource.Items.Add(l3);
b) button "Insert" (to move an item from Source to Destination):
foreach (ListItem li in lbxSource.Items)
{
if (li.Selected)
{
lbxDestination.Items.Add(li);
lbxDestination.SelectedItem.Value = "01";
li.Selected = false; //otherwise I got a runtime error 'multiple not
allowed in s
}
}
c) a "Show" button that shows the context of the Selected Destination Item:
tbxText.Text = lbxDestination.SelectedItem.Text;
And it's unbelievable, but tbxText.Text always shows "01", no matter what I
selected.
I had this in a real world application and since I couldn't believe it I
wrote a small test-page and it behaves exactly the same.
Is there a workaround to this ? Or am I doing something wrong ?
selection and lbxDestination -> single selection).
Then:
a) button "Load":
ListItem l0 = new ListItem("01");
lbxDestination.Items.Add(l0); //1st goes to Destination Box
ListItem l1 = new ListItem("02");
lbxSource.Items.Add(l1);
ListItem l2 = new ListItem("03");
lbxSource.Items.Add(l2);
ListItem l3 = new ListItem("04");
lbxSource.Items.Add(l3);
b) button "Insert" (to move an item from Source to Destination):
foreach (ListItem li in lbxSource.Items)
{
if (li.Selected)
{
lbxDestination.Items.Add(li);
lbxDestination.SelectedItem.Value = "01";
li.Selected = false; //otherwise I got a runtime error 'multiple not
allowed in s
}
}
c) a "Show" button that shows the context of the Selected Destination Item:
tbxText.Text = lbxDestination.SelectedItem.Text;
And it's unbelievable, but tbxText.Text always shows "01", no matter what I
selected.
I had this in a real world application and since I couldn't believe it I
wrote a small test-page and it behaves exactly the same.
Is there a workaround to this ? Or am I doing something wrong ?