代码之家  ›  专栏  ›  技术社区  ›  Jronny

带有telerik radgrid和linq to entity的crud

  •  1
  • Jronny  · 技术社区  · 16 年前

    我在想是否有可能在telerik radgrid上做crud,数据是从一个linq到实体的。

    我使用的是edmx,然后用linq查询得到的数据设置了Radgrid的数据源。这里是:

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

    雷达网是这样宣布的:

    <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>
    

    有什么办法可以这样编辑数据库内容吗?谢谢。

    1 回复  |  直到 16 年前
        1
  •  0
  •   Dick Lampard    16 年前

    Telerik grid支持使用数据源控件(LinqDataSource,EntityDataSource)作为MS GridView进行自动编辑。要执行手动CRUD,请使用NeedDataSource绑定并挂接服务器上的update/insert/delete事件-check this demo 一开始。