Hello!
I am having a RadAutoCompleteBox in the edit template form of my RadGrid. I am trying to bind it to a string array in my code behind file. The control is rendered but when I try to type in it I get DataSource(or DataSourceID) is not set error. Here are some code snippets:
ASCX
<
EditFormSettings
EditFormType
=
"Template"
>
<
FormTemplate
>
<
telerik:RadAutoCompleteBox
ID
=
"RadAutoCompleteBox1"
runat
=
"server"
DataSource="<%#AutoCompleteBoxDataSource%>" InputType="Token" AllowCustomEntry="true"></
telerik:RadAutoCompleteBox
>
</
FormTemplate
>
</
EditFormSettings
>
ASCX.CS
public
string
[] AutoCompleteBoxDataSource;
protected
void
Page_Load(
object
sender, EventArgs e)
{
AutoCompleteBoxDataSource =
new
string
[] {
"value1"
,
"value2"
,
"value3"
,
"value4"
};
}
protected
void
RadGrid_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
((e.Item
is
GridEditFormItem) && (e.Item.IsInEditMode))
{
GridEditFormItem editform = (GridEditFormItem)e.Item;
RadAutoCompleteBox racEditForm= (RadAutoCompleteBox)editform.FindControl(
"RadAutoCompleteBox1"
);
if
(racEditForm= !=
null
)
{
racEditForm.DataSource = AutoCompleteBoxDataSource;
racEditForm.DataBind();
}
}
}
I've tried removing the DataSource from the .ascx file but it caused a server error saying DataSource not set. I have another RadAutoCompleteBox control outside of the RadGrid which is working without any issues.
Thanks in advance!
Regards,
T.Toncheva