4 Answers, 1 is accepted
The RadSearchBox data source needs to be set earlier in the Page life cycle - in the Page_Load for example. Alternative way is to use SqlDataSource and set it in the markup code.
Regards,
Boyan Dimitrov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
Was interested reading this old post as the suggested solution didn't seem to make sense (and I have a similar issue).
The original post seems to suggest Shaun is trying to set the Datasource in ItemDataBound as there is a search box per row. If this is the case then I'm sure it's not possible to set the Datasource in Page_Load as the grid rows haven't yet been returned.
I am trying to add a RadSearchBox to a popup from a RadGrid - surely the Datasource HAS to be set in ItemDataBound? This is also what I have done and I get the "DataSource not set" alert.
As Page_load is not an option I'm kind of stuck. My current datasource declaration looks like this (within ItemDataBound) ...
if (e.Item is GridEditFormInsertItem)
{
GridEditFormInsertItem editform = e.Item as GridEditFormInsertItem;
RadSearchBox rsb1 = (RadSearchBox)editform.FindControl("RadSearchBox1");
rsb1.DataSource = GetTraineeRecords();
rsb1.DataTextField = "TraineeName";
rsb1.DataValueField = "TraineeID";
}
Try to handle SearchBox's OnInit event:
<
telerik:RadSearchBox
runat
=
"server"
ID
=
"searchBox"
OnInit
=
"searchBox_Init"
></
telerik:RadSearchBox
>
protected
void
searchBox_Init(
object
sender, EventArgs e)
{
(sender
as
RadSearchBox).DataSource = GetDataItem();
}
Does it help?
Regards,
Hristo Valyavicharski
Telerik