Autocompletebox value not binded in radgrid

4 posts, 0 answers
  1. Christophe
    Christophe avatar
    12 posts
    Member since:
    May 2015

    Posted 10 May 2015 Link to this post

    Hello,

    I have a Gridview with a autocompletbox and other types of fields inside. The gridview is binded by Sql (SqlDataSource1) and all fields are populated in both Item and Insert mode without any problem, except the Autocompletebox.

    The Autocompletebox works fine, meaning that it contains all the values from the SqlDataSource (SqlDataSource4 below) but the value that appears in the item mode (that uses SqlDataSource1) is not populated in editmode.

    What is wrong with my code to retreave the SqlDataSource1 value? A codebehind is needed?

    Thanks in advance.

     

    <MasterTableView DataSourceID="SqlDataSource1" AutoGenerateColumns="False" DataKeyNames="FlowID" CommandItemDisplay="Top " ItemStyle-CssClass="grid">

                    <Columns>
                        <telerik:GridBoundColumn DataField="BudgetCode" HeaderText="Budget" SortExpression="BudgetCode" UniqueName="BudgetCode" CurrentFilterFunction="Contains" AutoPostBackOnFilter="true" ShowFilterIcon="false" FilterControlWidth="80" HeaderStyle-Width="100"  ></telerik:GridBoundColumn>
                    </Columns>
                    <EditFormSettings EditFormType="Template">
                        <EditColumn ButtonType="ImageButton" />
                        <FormTemplate>
                                                    <telerik:RadAutoCompleteBox ID="ddlBudgetCode" runat="server" DataSourceID="SqlDataSource4" DataTextField="BudgetCode" DataValueField="BudgetCodeId" InputType="Token">
                                                    </telerik:RadAutoCompleteBox>
                        </FormTemplate>
                    </EditFormSettings>
                </MasterTableView>


  2. Ivan Danchev
    Admin
    Ivan Danchev avatar
    837 posts

    Posted 13 May 2015 Link to this post

    Hello,

    Since the RadAutoCompleBox is rebinding when it is embedded in a RadGrid's FormTemplate you can use Session to save the entry text and show it after the RadAutoCompleteBox is loaded again. For example:
    protected void RadAutoCompleteBox1_Init(object sender, EventArgs e)
    {
        RadAutoCompleteBox box = sender as RadAutoCompleteBox;
        if ( Session["BoxText"] != null)
        {
            box.Entries.Insert(0, new AutoCompleteBoxEntry(Session["BoxText"].ToString()));
        }
    }
     
    protected void RadAutoCompleteBox1_TextChanged(object sender, AutoCompleteTextEventArgs e)
    {
        Session["BoxText"] = e.Text;
    }

    <telerik:RadAutoCompleteBox ID="RadAutoCompleteBox1" runat="server" Width="300" MaxResultCount="5"
        DropDownHeight="200" DataSourceID="SqlDataSource2" DataTextField="ContactName" EmptyMessage="Select Customers"
        DataValueField="CustomerID" AutoPostBack="true" OnInit="RadAutoCompleteBox1_Init" InputType="Text" OnTextChanged="RadAutoCompleteBox1_TextChanged">   
    </telerik:RadAutoCompleteBox>

    Regards,
    Ivan Danchev
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Christophe
    Christophe avatar
    12 posts
    Member since:
    May 2015

    Posted 13 May 2015 in reply to Ivan Danchev Link to this post

    Thank you Ivan,

    I tried your solution but it did not change anything.

    By what must I replace "BoxText"? The DataKeyNames of the Radgrid?

  5. Ivan Danchev
    Admin
    Ivan Danchev avatar
    837 posts

    Posted 15 May 2015 Link to this post

    Hello,

    If I understood correctly your issue is loosing the RadAutoCompleteBox entry in the RadGrid's FormTemplate. I am attaching a sample runnable project with included sample databases which demonstrate how the entry can be preserved using the session.

    Please, run the web site and let us know if that is the behavior you expect, otherwise please explain step-by-step the user actions and the expected outcome so we can get a better idea what you are trying to achieve. You can use the attached sample web site to reproduce the issue and post your modifications. This would help us understand the specifics of your case.

    The Telerik .dll files are removed from the Bin folder in order not to exceed the maximum allowed attachment size.

    Regards,
    Ivan Danchev
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
Back to Top