Filling RadComboBox in listview editItemTemplate programatically

3 posts, 0 answers
  1. Caglar Duman
    Caglar Duman avatar
    10 posts
    Member since:
    Jun 2010

    Posted 10 Jul 2010 Link to this post

    Hi,

    I want to fill radcombobox in listview editItemTemplate programatically.
    Where should I fill it? 

    Should I fill in listview ItemDataBound event? or listview ItemCreated event? or something else?

    Simple Code that I wrote:
    protected void listview1_ItemDataBound(object sender, RadListViewItemEventArgs e)
    {
       if (e.Item is RadListViewEditableItem && e.Item.IsInEditMode)
       {
          RadComboBox cmb = e.Item.FindControl("cmbTest") as RadComboBox;
     
          if (cmb != null)
          {
             fillCombo(cmb); //databinds the combo
          }
       }
    }
     
    protected void fillCombo(RadComboBox cmb)
    {
      cmb.DataSource = MngCon.Fill(ParameterConstants.PERSON);
      cmb.DataTextField = "NAME";
      cmb.DataValueField = "ID";
      cmb.DataBind();
    }


    PS: when I try to enter comboBox -> SelectedValue='<%# Bind("PERSONID") %>'  it gives me an error; Selection out of range.
  2. Caglar Duman
    Caglar Duman avatar
    10 posts
    Member since:
    Jun 2010

    Posted 10 Jul 2010 Link to this post

    Why I can't see my post ??
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 12 Jul 2010 Link to this post

    Hello Caglar,

    You can use DataBinding event of the RadComboBox instead.

    protected void RadComboBox1_DataBinding(object sender, EventArgs e)
    {
        var comboBox = ((RadComboBox)sender);
        fillCombo(comboBox);      
    }

    Sincerely yours,
    Rosen
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top