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

Filling RadComboBox in listview editItemTemplate programatically

2 Answers 150 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Caglar Duman
Top achievements
Rank 1
Caglar Duman asked on 11 Jul 2010, 12:48 AM
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 Answers, 1 is accepted

Sort by
0
Caglar Duman
Top achievements
Rank 1
answered on 11 Jul 2010, 01:00 AM
Why I can't see my post ??
0
Rosen
Telerik team
answered on 12 Jul 2010, 09:35 AM
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
Tags
ListView
Asked by
Caglar Duman
Top achievements
Rank 1
Answers by
Caglar Duman
Top achievements
Rank 1
Rosen
Telerik team
Share this question
or