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

RadAutoCompleteTextbox to load other textbox

3 Answers 24 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brad
Top achievements
Rank 1
Brad asked on 30 Oct 2013, 05:30 PM
I have a RadAutoCompleteTextbox that loads a list of descriptions that a user is able to start typing and choose from, but i want to be able to do the following, as soon as  user chooses one of the available descriptions it loads the amount text box for it. How can i accomplish that?

I have the folllwing code for the autocomplete box, which works fine

private void grid_ItemCreated(object sender, GridItemEventArgs e)
    {

        if (e.Item is GridEditableItem && e.Item.IsInEditMode)
        {
            GridEditableItem editableItem = e.Item as GridEditableItem;
            TableCell cell = editableItem["Description"];
            if (cell.Controls.Count > 0 && cell.Controls[0] is RadAutoCompleteBox)
            {
                ((RadAutoCompleteBox)(cell.Controls[0])).TextSettings.SelectionMode = RadAutoCompleteSelectionMode.Single;
                ((RadAutoCompleteBox)(cell.Controls[0])).AllowCustomEntry = false;
                ((RadAutoCompleteBox)(cell.Controls[0])).DataSource = GetTableForAuto();
            }
        }

    }

What event is called when a user chooses a selection from the autocompletebox, and how would i be able to add the text for a different textbox?

3 Answers, 1 is accepted

Sort by
0
Brad
Top achievements
Rank 1
answered on 03 Nov 2013, 10:20 PM
anyone?
0
Brad
Top achievements
Rank 1
answered on 07 Nov 2013, 05:16 PM
Is this not possible?
0
Princy
Top achievements
Rank 2
answered on 08 Nov 2013, 10:17 AM
Hi Brad,

Please try the following code snippet. I have tried to set text in textbox in edit mode on the Selection of RadAutoCompleteBox selection.

ASPX:
<telerik:GridTemplateColumn HeaderText="ShipCountry">
    <ItemTemplate>
        <asp:Label ID="Label1" runat="server" Text='<%#Eval("ShipCountry") %>'></asp:Label>
    </ItemTemplate>
    <EditItemTemplate>
        <telerik:RadAutoCompleteBox ID="RadAutoCompleteBox" runat="server" Width="200" DropDownWidth="200"
            AutoPostBack="true" AllowCustomEntry="false" DropDownHeight="200" DataSourceID="SqlDataSource2"
            DataTextField="ShipCountry" TextSettings-SelectionMode="Single" DataValueField="ShipCountry"
            OnEntryAdded="RadAutoCompleteBox_EntryAdded">
        </telerik:RadAutoCompleteBox>
    </EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn DataField="ShipCity" HeaderText="ShipCity" UniqueName="ShipCity" />

C#:
protected void RadAutoCompleteBox_EntryAdded(object sender, AutoCompleteEntryEventArgs e)
{
    RadAutoCompleteBox autocompletebox = (RadAutoCompleteBox)sender;
    GridEditableItem edit = (GridEditableItem)autocompletebox.NamingContainer;
    string val = autocompletebox.Text; // Get the Value added to RadAutoCompleteBox
    TextBox txt = (TextBox)edit["ShipCity"].Controls[0];
    txt.Text = "Your Required Text";
}

Thanks,
Princy
Tags
Grid
Asked by
Brad
Top achievements
Rank 1
Answers by
Brad
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or