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

Autocomplete column based on dropdown

2 Answers 27 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brad
Top achievements
Rank 1
Brad asked on 16 Oct 2013, 09:32 PM
Is it possible to have a dropdown column, and based on whats chosen in the dropdown column, it then autocompletes a text column within a grid? If so, does anyone have an example on how to do that?

2 Answers, 1 is accepted

Sort by
0
Brad
Top achievements
Rank 1
answered on 20 Oct 2013, 02:46 PM
Has anyone ever done this before?
0
Viktor Tachev
Telerik team
answered on 21 Oct 2013, 03:14 PM
Hi Brad,

The GridDropDownColumn is displayed as a dropdown control only when it is in edit mode. When the RadGrid is in browser mode the column is displayed as a normal GridBoundColumn.

The populating of the value in the TextBox could happen in SelectedIndexChanged event handler for the DropDownList control. To attach this handler to the control you could use the RadGrid's ItemCreated event.

protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item is GridEditableItem && e.Item.IsInEditMode)
    {
        GridEditableItem editableItem = e.Item as GridEditableItem;
        DropDownList dropDownList = editableItem["ColumnUniqueName"].Controls[0] as DropDownList;
        dropDownList.SelectedIndexChanged += dropDownList_SelectedIndexChanged;
 
        // execute custom logic
    }
}

void
dropDownList_SelectedIndexChanged(object sender, EventArgs e)
{
    // populate value for TextBox control
}


Additional information on accessing cells and rows for the RadGrid is available in this article.

If I have misunderstood your scenario could you elaborate more on what you would like to achieve?

Regards,
Viktor Tachev
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
Brad
Top achievements
Rank 1
Answers by
Brad
Top achievements
Rank 1
Viktor Tachev
Telerik team
Share this question
or