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

RadListBox removing items after adding new item

1 Answer 98 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Saquib
Top achievements
Rank 1
Saquib asked on 27 Apr 2013, 07:35 PM
Hello,

I have two RadListBoxes and a button in my page, my requirement is after clicking the button the selected items in RadListBox1 should move to RadListBox2.

<telerik:RadListBox ID="RadListBox1" Width="200px" Height="300px"
     SelectionMode="Multiple" runat="server"></telerik:RadListBox>
<telerik:RadListBox ID="RadListBox2" Width="300px" Height="300px" runat="server">
     </telerik:RadListBox>

void button1_Click(object sender, EventArgs e)
{
  foreach (RadListBoxItem selectedItem in RadListBox1.SelectedItems)
  {
     RadListBox2.Items.Add(
new RadListBoxItem(selectedItem.Text));
  }
}

My problem is every time I click the button its removing already present item in RadListBox2 and adding the the currently selected item of RadListBox1. I want it to append the item to the already existing items of RadListBox2.

Can anyone help me here please.

Thanks,
Saquib

1 Answer, 1 is accepted

Sort by
0
Saquib
Top achievements
Rank 1
answered on 28 Apr 2013, 09:23 PM
Never mind on this one, I had the view state of the page set to false. For my anger, false is the default value for view state on page level in Sitefinity (for those who know Sitefinity).


-Saquib 
Tags
ListBox
Asked by
Saquib
Top achievements
Rank 1
Answers by
Saquib
Top achievements
Rank 1
Share this question
or