SearchBox in Grid EditForm

5 posts, 0 answers
  1. Shaun
    Shaun avatar
    5 posts
    Member since:
    Jun 2012

    Posted 12 Jan 2015 Link to this post

    Trying to set RadSearchBox Datasource in  Grid ItemDataBound event but only get message saying DataSource not set.
  2. Boyan Dimitrov
    Boyan Dimitrov avatar
    1728 posts

    Posted 15 Jan 2015 Link to this post


    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.

    Boyan Dimitrov

    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.

  3. DevCraft R3 2016 release webinar banner
  4. Paul
    Paul avatar
    2 posts
    Member since:
    Apr 2014

    Posted 05 Aug 2015 in reply to Boyan Dimitrov Link to this post

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


  5. Paul
    Paul avatar
    2 posts
    Member since:
    Apr 2014

    Posted 06 Aug 2015 in reply to Paul Link to this post

    Will open a separate support post to request help.
  6. Hristo Valyavicharski
    Hristo Valyavicharski avatar
    975 posts

    Posted 06 Aug 2015 Link to this post

    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?

    Hristo Valyavicharski
    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
Back to Top
DevCraft R3 2016 release webinar banner