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

DataSource Issue within RadGrid

1 Answer 72 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Rengo
Top achievements
Rank 1
Rengo asked on 02 Apr 2013, 03:42 PM
Hello,

I have a RadAutoCompleteBox control within a RadGrid.  I am able to bind the control during the page load.  Although, when I start typing in the RadAutoCompletebox, I receive the following message.



Grid HTML:
 <telerik:GridTemplateColumn HeaderText="Media Title" UniqueName="MediaTitle" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Width="330px"  ItemStyle-Wrap="false">
                <ItemTemplate>
                   <telerik:RadAutoCompleteBox ID="cboMaster" InputType="Text" runat="server" Filter="Contains" Width="300px" DropDownWidth="250px">
                    </telerik:RadAutoCompleteBox>
                  </ItemTemplate>
                </telerik:GridTemplateColumn>

RadAutoCompleteBox Binding (Page_Load):
 cboMaster.DataValueField = "ID";
 cboMaster.DataTextField = "Title";
 cboMaster.DataSource = GetMediaSourceTitles();
 cboMaster.DataBind();

What am I missing so users can type in the RadAutoCompleteBox and display the matching entries?

Thank You in Advance!

1 Answer, 1 is accepted

Sort by
0
Nencho
Telerik team
answered on 05 Apr 2013, 02:26 PM
Hello Robert,

I would suggest you to use the OnItemDataBound event, instead of the Page_Load, since the RadGrid is not completely initiated at that stage of the life cycle. Please consider the following implementation:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem dataItem = e.Item as GridDataItem;
            RadAutoCompleteBox cboMaster = dataItem["MediaTitle"].Controls[1] as RadAutoCompleteBox;
            cboMaster.DataValueField = "ID";
            cboMaster.DataTextField = "Title";
            cboMaster.DataSource = GetMediaSourceTitles();
            cboMaster.DataBind();
        }
    }




Greetings,
Nencho
the Telerik team
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 their blog feed now.
Tags
AutoCompleteBox
Asked by
Rengo
Top achievements
Rank 1
Answers by
Nencho
Telerik team
Share this question
or