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

RadComboBox databind ondemand

1 Answer 240 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Marjan asked on 07 Jul 2008, 07:37 AM

I try to implement custom control (inherit RadComboBox). For customize dropdownList I make the class for radcombobox.ItemTemplate. In this class in InstantiateIn method add some labels with DataBinding eventhandler.

I also set event ItemsRequested for data load ondemad:
void RadComboBox_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)
int noItems = 15;

RadComboBox combo = (RadComboBox)o;
combo.DataSourceID =
combo.DataSource =
String sortExpression = this.Sort.SelectedValue;

// new datasource
ObjectDataSource ods = new ObjectDataSource("Artikli", "GetArtikliPagedSortedKlas");
// set parameters
ods.SelectParameters.Add("maximumRows", noItems.ToString());
"sortExpression", sortExpression);
//.... // there are more parameters. Those parameters must set at this point(depends from other controls)

combo.DataSource = ods;
// There get the message InvalidOperationException ONLY IF PUT THE CONTROL IN FORMVIEW(on edit)
//Error message:"Databinding methods such as Eval(), XPath(), and Bind() can only be used in 
the context of a databound control."

 The new control works fine until I don't databind it. My case:put it on the FormView, databind and on run time choose edit(insert i did't try).

To summarize:

  1.  How to databind ondemad. In DropDownList header I have some extra controls on which values depends query to database.
  2. How to determine what is select for first time when user choose edit in FormView - to prepare a query which included rigt row.
  3. If in custom control add a new public property, put the control into FormView itemtemplate and bind any field get the error:(There was an error rendering the control. Cannot create an object of type 'System.Collections.Generic.List`1......) Set attribute [Bindable(false)] doesn't solve problem.

 The solution must be acteptable also for radgrid and gridview.

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 07 Jul 2008, 01:48 PM
Hi Marjan,

Please read this article for more detailed information about the problem.

Kind regards,
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question