Hello,
Iam trying to add all the values from the left listbox (OA) into the right listbox(NA) but the values may not be duplicated. If the values are the same it must be increased with 1 until it is not duplicated.
This is probably very simple but it doesn't seem to work (and im kinda new to C# to be honest haha).
thanks in advance !
Wouter
UPDATE:
code:
Iam trying to add all the values from the left listbox (OA) into the right listbox(NA) but the values may not be duplicated. If the values are the same it must be increased with 1 until it is not duplicated.
This is probably very simple but it doesn't seem to work (and im kinda new to C# to be honest haha).
thanks in advance !
Wouter
UPDATE:
code:
|
Deepak BhatiaPosted Jul 4, 2010, 9:27 AM
Sorry I was late in responding as there were no lights at my house due to rainfall.
It's quiet easy.
Just see the code it will be helpful
These are two list box
<asp:ListBox ID="leftListBox" runat="server">
<asp:ListItem Text="Hello" Value="Hello">asp:ListItem>
<asp:ListItem Text="Hi" Value="Hi">asp:ListItem>
<asp:ListItem Text="Hello" Value="Hello">
asp:ListItem>
asp:ListBox>
<asp:ListBox ID="rightListBox" runat="server">asp:ListBox>
I believe that data is already assigned in left list box,
Now just add these function and call it when you need it
private void ShiftDataFromLeftToRightListBox()
{
foreach (ListItem leftItem in leftListBox.Items)
{
if (!rightListBox.Items.Contains(leftItem))
{
rightListBox.Items.Add(leftItem);
}
}
}
WouterPosted Jul 4, 2010, 7:57 AM
If I encounter a duplicate the leftvalue needs to be raised until it is unique and then it has to be placed in the right listbox.
maybe it is more clear if I tell what we needed to make:
In a hospital a doctor dies, now all his appointments(left listbox) need to be taken over by a user selected doctor(right listbox).
the values also have to be between 8 and 17(this is not included in the code I know) because that are the working hours.
thank you !
Deepak BhatiaPosted Jul 4, 2010, 7:49 AM
I am little confused wih your question, Is it that you want to copy only distinct values from one listbox to other.
And if you encounter a duplicate entry what is to be done.