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

Databinding with ControlParameter

5 Answers 123 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 15 Dec 2008, 03:03 PM
Hi,

I have a RadGrid which is bound to a LinqDataSource. In the where parameter of the datasource I have a ControlParameter which references a RadComboBox. With this setup the content of the grid changes when the selection of the combo box changes. So far so good. The problem is, that on page load the combobox is bound to its datasource and displays its contents but the grid does not. The grid is updated when I firs change the selection of the combo box.
How can I fill the grid proprtly on page load?

Best regards,
Robert

5 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 15 Dec 2008, 03:10 PM
Hello Robert,

You can set DefaultValue for this ControlParameter to achieve your goal.

Regards,
Vlad
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Robert
Top achievements
Rank 1
answered on 15 Dec 2008, 05:13 PM
Hi Vlad,

thank your for your reply. What could be a useful value for the "DefaultValue" property? The problem is, that the default value depends on the combo box's data items. I cannot hardcode this value since the data which the combobox is bound to can change and then the "DefaultValue" property would also have to change.

Best regards,
Robert
0
Vlad
Telerik team
answered on 16 Dec 2008, 07:43 AM
Hello Robert,

I've attached small example.

Let me know if you have any questions.

Greetings,
Vlad
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Robert
Top achievements
Rank 1
answered on 16 Dec 2008, 08:58 AM
Hi Vlad,

thank you for that example project. It helped me to resolve the problem. The error was caused by the "Filter" property of the combo box which was set to "Contains". After removing this property it worked well. Now, I set the "Filter" property in codebehind after databinding the combo box which works as expected. Do you have an idea, why the Filter did prevent the combo box from selecting it's first item?
0
Simon
Telerik team
answered on 20 Dec 2008, 05:52 PM
Hello Robert,

Indeed the inconsistency is observable in the project posted by Vlad.

We will look further into it and in the meanwhile I suggest you use the following workaround: handle the OnDataBound event of the ComboBox and select its first Item (or another based on some business logic).

Regards,
Simon
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Robert
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Robert
Top achievements
Rank 1
Simon
Telerik team
Share this question
or