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

SearchBox in Grid EditForm

4 Answers 97 Views
SearchBox
This is a migrated thread and some comments may be shown as answers.
Shaun
Top achievements
Rank 1
Shaun asked on 12 Jan 2015, 09:30 PM
Trying to set RadSearchBox Datasource in  Grid ItemDataBound event but only get message saying DataSource not set.

4 Answers, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 15 Jan 2015, 11:50 AM
Hello,

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.

 
0
Philip
Top achievements
Rank 1
answered on 05 Aug 2015, 04:04 PM

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";
}

 

0
Philip
Top achievements
Rank 1
answered on 06 Aug 2015, 09:48 AM
Will open a separate support post to request help.
0
Hristo Valyavicharski
Telerik team
answered on 06 Aug 2015, 01:21 PM
Hi Paul,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
SearchBox
Asked by
Shaun
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Philip
Top achievements
Rank 1
Hristo Valyavicharski
Telerik team
Share this question
or