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

LINQ as a DataSource for RadGrid

1 Answer 277 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 21 Jan 2011, 12:56 AM
Greetings,

How do I (cast) ServiceParentList.AsEnumerable() this so can make this a DataSource for the Grid?

Please let me know if this correct or there is a better way to do this :)

 protected void radGridRate_DetailTableDataBind(object sender, GridDetailTableDataBindEventArgs e)
        {
            GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem;

            System.Diagnostics.Debug.WriteLine("e.DetailTableView: " + e.DetailTableView.Name);

            switch (e.DetailTableView.Name)
            {
                case "ServiceParent":
                    {
                        radGridRate.MasterTableView.DetailTables[0].ShowHeader = true;

                        string ServiceName = dataItem.GetDataKeyValue("ServiceName").ToString();
                        DataTable dtServiceParent = (DataTable)Session["dtServicesParent"];

                        var ServiceParentList = from tinRecord in dtServiceParent.AsEnumerable()
                                                orderby tinRecord.Field<string>("ServiceName")
                                                where tinRecord.Field<string>("ServiceName") == ServiceName
                                                select new
                                                {
                                                    ServiceName = tinRecord.Field<string>("ServiceName"),
                                                    ParentName = tinRecord.Field<string>("ParentName")
                                                };

                        e.DetailTableView.DataSource = (DataSet) ServiceParentList.AsEnumerable();
etc...

Thanks!
Dave Gilden MCSD / Ft. Worth Tx.

1 Answer, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 26 Jan 2011, 08:29 AM
Hi David,

Your approach is valid and should work all right. RadGrid accepts both IEnumerable and IQueryable objects.

Hope it helps.

Best wishes,
Tsvetoslav
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Grid
Asked by
David
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Share this question
or