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

Autocompletebox value not binded in radgrid

3 Answers 94 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Christophe
Top achievements
Rank 1
Christophe asked on 10 May 2015, 06:40 AM

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>


3 Answers, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 13 May 2015, 03:59 PM
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
0
Christophe
Top achievements
Rank 1
answered on 13 May 2015, 05:20 PM

Thank you Ivan,

I tried your solution but it did not change anything.

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

0
Ivan Danchev
Telerik team
answered on 15 May 2015, 01:47 PM
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
Tags
AutoCompleteBox
Asked by
Christophe
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Christophe
Top achievements
Rank 1
Share this question
or