Failed to add a single RadItem into Multiple RadComboboxes

2 posts, 0 answers
  1. Joshua
    Joshua avatar
    35 posts
    Member since:
    May 2012

    Posted 30 Jul 2012 Link to this post

    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);

           
    }
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 31 Jul 2012 Link to this post

    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.
Back to Top