开发者

crud with telerik radgrid and linq to entity

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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜