views:

343

answers:

1

I was thinking if is it possible to do crud on telerik radgrid and the data were from a linq to entity.

I was using edmx, then I have set Radgrid's DataSource with data resulting from a linq query. Here it goes:

DatabaseModel.Entities entities = new DatabaseModel.Entities();
RadGrid1.DataSource = from courses in entities.Courses
                      select new {
                          courses.CourseName,
                          courses.CourseCode,
                          courses.Description
                      };
RadGrid1.DataBind();

and the Radgrid was declared this way:

<telerik:RadGrid ID="RadGrid1" runat="server"
    AllowAutomaticDeletes="true"  AllowAutomaticInserts="true" 
    AllowAutomaticUpdates="true" AllowPaging="True" 
    AutoGenerateDeleteColumn="True" EnableHeaderContextMenu="True" 
    AllowFilteringByColumn="True" AllowSorting="True" AutoGenerateEditColumn="True">
    <MasterTableView CommandItemDisplay="Top"  >
    </MasterTableView>
</telerik:RadGrid>

Is there any way we could edit the db contents this way? Thanks a lot.

A: 

Telerik grid supports automatic editing with data source controls (LinqDataSource, EntityDataSource) as the MS GridView. To perform manual CRUD, use NeedDataSource binding and hook the update/insert/delete events on the server - check this demo for a start.

Dick Lampard