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

Filtering radgrid with external control

1 Answer 105 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Garrett
Top achievements
Rank 1
Garrett asked on 04 Oct 2013, 03:40 PM
Hi again :)

I have a radgrid that I want to filter exactly like they do in this example:

http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridcomboajax/defaultcs.aspx?product=grid


the problem though is that I am not using a sqldatasource because the items in the grid need to be editable, so I am getting the source from the code behind.

Here is how the grid is getting it's data source:

protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            loadGrid();
        }
 
    }
 
    protected void loadGrid()
    {
        DATABASE dbcontext = new DATABASE();
        IEnumerable<LineItem> newlineitem = from p in dbcontext.LineItems
                                            select p;
        gridDataSource = newlineitem;
        RadGrid1.Rebind();
    }
 
public IEnumerable<LineItem> gridDataSource
    {
        set
        {
            Session["gridDataSource"] = value;
        }
        get
        {
            if (Session["gridDataSource"] == null)
                return null;
            else
            {
                return ((IEnumerable<LineItem>)Session["gridDataSource"]);
            }
        }
    }
 
protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
    {
        RadGrid1.DataSource = gridDataSource;
    }


How can I achieve this?

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 09 Oct 2013, 01:41 PM
Hi Garrett,

Please remove the initial loadGrid logic and set the datasource of the grid only during NeedDataSource event.

Hope this helps. Looking forward to your reply.

Regards,
Eyup
Telerik
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 the blog feed now.
Tags
Grid
Asked by
Garrett
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or