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

ComboBox SelectedValue in ListView EditItemTemplate

2 Answers 150 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Caglar Duman
Top achievements
Rank 1
Caglar Duman asked on 15 Jul 2010, 01:37 PM
Hi,

I've a ComboBox in ListView EditItemTemplate and I'm filling it programatically;
aspx file
...
<EditItemTemplate>
   <telerik:RadComboBox ID="cmb" runat="server" SelectedValue='<%#Bind("KAYITNO")%>'>
   </telerik:RadComboBox>
</EditItemTemplate>
...

cs file
...
protected void listView_ItemCreated(object sender, RadListViewItemEventArgs e)
{
     if (e.Item.ItemType == RadListViewItemType.EditItem)
     {
         RadComboBox cmb= item.FindControl("cmb") as RadComboBox;
         fillCombo(cmb);
     }
}
 
protected void fillCombo(RadComboBox cmb)
{
   cmb.DataSource = MngCon.Fill();
   cmb.DataTextField = "VALUE";
   cmb.DataValueField = "KAYITNO";
   cmb.DataBind();
}
...


The problem is that when I press edit button EditItemTemplate thow exception; 

Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.

What can I do for this situation ?

PS: I'm sure that Bind("KAYITNO") value is exists in comboBox items.

2 Answers, 1 is accepted

Sort by
0
Caglar Duman
Top achievements
Rank 1
answered on 15 Jul 2010, 01:46 PM

I've removed  "cmb.DataBind()" -> now it works great :)
but why DataBind can't be used?
0
Veronica
Telerik team
answered on 15 Jul 2010, 04:13 PM
Hello Caglar Duman,

This error appears if at some moment  the RadListBox is not binded and SelectedValue cannot find the argument of the Bind expression.

Could you please send us the full code so we can inspect it and help you.

Thank you!

Kind regards,
Veronica Milcheva
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
ComboBox
Asked by
Caglar Duman
Top achievements
Rank 1
Answers by
Caglar Duman
Top achievements
Rank 1
Veronica
Telerik team
Share this question
or