RadComboBox values datasource and data binding from another datasource

2 posts, 0 answers
  1. Keiichi-kun
    Keiichi-kun avatar
    14 posts
    Member since:
    Dec 2010

    Posted 06 Oct 2015 Link to this post

    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

  2. Keiichi-kun
    Keiichi-kun avatar
    14 posts
    Member since:
    Dec 2010

    Posted 06 Oct 2015 in reply to Keiichi-kun Link to this post

    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

  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top