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

Failed to add a single RadItem into Multiple RadComboboxes

1 Answer 61 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Joshua
Top achievements
Rank 1
Joshua asked on 30 Jul 2012, 07:28 PM

All I'm really trying to do is populate three different comboboxes with the same item. When this code executes below only one combobox is getting the values. Any help is welcomed. Thanks!

for (int i = 0; i < 100; i++)
       
{
           
RadComboBoxItem li = new RadComboBoxItem();
            li
.Text = i.ToString();
            li
.Value = i.ToString();
           
InputPairThousandValueComboBox.Items.Add(li);
           
InputUsertThousdandValueComboBox.Items.Add(li);
           
InputCurrentlyListedThousdandComboBox.Items.Add(li);

       
}

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 31 Jul 2012, 06:01 AM
Hi Joshua,

I too could replicate your issue. One suggestion is that you can create different objects for different comboboxes as follows.

C#:
protected void Page_Load(object sender, EventArgs e)
{
  if (!IsPostBack)
  {
   for (int i = 0; i < 100; i++)
   {
    RadComboBoxItem li = new RadComboBoxItem();
    li.Text = i.ToString();
    li.Value = i.ToString();
    InputPairThousandValueComboBox.Items.Add(li);
    RadComboBoxItem li1 = new RadComboBoxItem();
    li1.Text = i.ToString();
    li1.Value = i.ToString();
    InputUsertThousdandValueComboBox.Items.Add(li1);
    RadComboBoxItem li2 = new RadComboBoxItem();
    li2.Text = i.ToString();
    li2.Value = i.ToString();
    InputCurrentlyListedThousdandComboBox.Items.Add(li2);
   }
  }
}
 
Thanks,
Princy.
Tags
ComboBox
Asked by
Joshua
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or