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

RadComboBox values datasource and data binding from another datasource

1 Answer 348 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Keiichi-kun
Top achievements
Rank 1
Keiichi-kun asked on 06 Oct 2015, 10:53 AM

Hi all,
I've a RadComboBox inside EditItemTemplate

1.<telerik:RadComboBox Skin="Silk" ID="cognome_sostituto_combo" runat="server" DataSourceID="SqlDataSourceGiocatori1" DataTextField="Cognome" DataValueField="Cognome" DropDownWidth="200px" MinFilterLength="2" Filter="StartsWith" AllowCustomText="false" Text='<%# Bind("Cognome_sostituto")%>' >

(NOTE: this code is inside a GridView with <Columns><TemplateField>)

My scope is:

- populate combo with items from SqlDataSourceGiocatori1 (that has a query like select cognome from ....) --> done
- set selected item from SqlDataSource connected to GridView --> not working using Text='<%# Bind... --> not working

If I use, for example, a TextBox and bind Text with Text='<%# Bind("Cognome_sostituto")%>' everything is ok but there's no autocomplete.

The error I get is "Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control"  

Any ideas?

Thanks for your help

1 Answer, 1 is accepted

Sort by
0
Keiichi-kun
Top achievements
Rank 1
answered on 06 Oct 2015, 12:39 PM

Nevermind!

This solution works great

<telerik:RadComboBox ViewStateMode="Disabled" Skin="Silk" ID="cognome_sostituto_combo" runat="server" DataSourceID="SqlDataSourceGiocatori1" DataTextField="Cognome"
DataValueField="Cognome" DropDownWidth="200px" MinFilterLength="2" Filter="StartsWith" AllowCustomText="false"
SelectedValue='<%#Bind("Cognome_sostituto")%>' >
</telerik:RadComboBox>

maybe during tests I've never tried with another field name in Bind ​combined with SelectedValue

Bye

Tags
ComboBox
Asked by
Keiichi-kun
Top achievements
Rank 1
Answers by
Keiichi-kun
Top achievements
Rank 1
Share this question
or