Hi,
I am sure that this is a nice easy question, been playing with the RadGrid for the past hour (newbie to Telerik) and cannot get it to work in the way I would expect with advanced data binding.
I am using LINQ for SQL, if I use a LINQDataSource on the page then everything works as expected however if I try to bind a custom data query in the code behind I am presented with an empty Grid (same query works ok with a normal GridView object).
In the little research I have done I have discovered that the NeedDataSource event should be used and in this scenario .DataBind is not necessary so my code looks as follows:
I am sure that this is a nice easy question, been playing with the RadGrid for the past hour (newbie to Telerik) and cannot get it to work in the way I would expect with advanced data binding.
I am using LINQ for SQL, if I use a LINQDataSource on the page then everything works as expected however if I try to bind a custom data query in the code behind I am presented with an empty Grid (same query works ok with a normal GridView object).
In the little research I have done I have discovered that the NeedDataSource event should be used and in this scenario .DataBind is not necessary so my code looks as follows:
protected
void RadGrid_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
DataClassesDataContext MyData = new DataClassesDataContext();
var LINQQuery = from MyObject in MyData.Objects
select new
{
Object_Type = MyObject.Object_Type.Name,
Owner = MyObject.Owner_ID
};
RadGrid.DataSource = LINQQuery;
}
On execution my RadGrid object shows no data (if I put the exact same query in the Page_Load event with DataBinf and assign it to a normal GridView then it works no problem.
I am sure I am missing something obvious but it's late so I need somebody to point it out.
Many thanks,
Tim