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

CRUD operations don't work with EntityDataSource

1 Answer 81 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 23 Jun 2012, 04:54 PM
Hi all, I upgraded my webpages to NET 4 and i'm using the EntityFramework abilities, I working with Mysql database, cause i develop on php and .NET and using the Mysql .NET connector v 6.4.4 for Visual Studio 2010.
I tried to bind RadGrid (v 2012.1) with the EntityDataSource, it reads whole rows but CRUD operations on RadGrid didn't work, my surprise was CRUD works on original ASP.NET GridView  with EntityDS. here is my default.aspx code.

<%@ Page Language="C#" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
 
</script>
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        <Scripts>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js">
            </asp:ScriptReference>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js">
            </asp:ScriptReference>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js">
            </asp:ScriptReference>
        </Scripts>
    </telerik:RadScriptManager>
    <asp:EntityDataSource ID="EntityDataSourceTest" runat="server" ConnectionString="name=entity_testEntities"
        DefaultContainerName="entity_testEntities" EnableDelete="True" EnableFlattening="False"
        EnableInsert="True" EnableUpdate="True" EntitySetName="test_table">
    </asp:EntityDataSource>
    <br />
    Gridview<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="id"
        DataSourceID="EntityDataSourceTest">
        <Columns>
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
            <asp:BoundField DataField="id" HeaderText="id" ReadOnly="True" SortExpression="id" />
            <asp:BoundField DataField="test1" HeaderText="test1" SortExpression="test1" />
            <asp:BoundField DataField="test2" HeaderText="test2" SortExpression="test2" />
            <asp:BoundField DataField="test3" HeaderText="test3" SortExpression="test3" />
        </Columns>
    </asp:GridView>
    <br />
    RadGrid<br />
    <telerik:RadGrid ID="RadGrid1" runat="server" CellSpacing="0" DataSourceID="EntityDataSourceTest"
        GridLines="None" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True">
        <ClientSettings>
            <Selecting CellSelectionMode="None"></Selecting>
        </ClientSettings>
        <MasterTableView AutoGenerateColumns="False" DataKeyNames="id" DataSourceID="EntityDataSourceTest"
            AllowAutomaticDeletes="False" AllowAutomaticInserts="False" AllowAutomaticUpdates="False"
            CommandItemDisplay="Top">
            <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
            <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
                <HeaderStyle Width="20px"></HeaderStyle>
            </RowIndicatorColumn>
            <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
                <HeaderStyle Width="20px"></HeaderStyle>
            </ExpandCollapseColumn>
            <Columns>
                <telerik:GridEditCommandColumn ButtonType="ImageButton" FilterControlAltText="Filter EditCommandColumn column">
                </telerik:GridEditCommandColumn>
                <telerik:GridBoundColumn DataField="id" DataType="System.Int64" FilterControlAltText="Filter id column"
                    HeaderText="id" ReadOnly="True" SortExpression="id" UniqueName="id">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="test1" FilterControlAltText="Filter test1 column"
                    HeaderText="test1" SortExpression="test1" UniqueName="test1">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="test2" FilterControlAltText="Filter test2 column"
                    HeaderText="test2" SortExpression="test2" UniqueName="test2">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="test3" FilterControlAltText="Filter test3 column"
                    HeaderText="test3" SortExpression="test3" UniqueName="test3">
                </telerik:GridBoundColumn>
                <telerik:GridButtonColumn CommandName="Delete" ButtonType="ImageButton">
                </telerik:GridButtonColumn>
            </Columns>
            <EditFormSettings>
                <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                </EditColumn>
            </EditFormSettings>
        </MasterTableView>
        <FilterMenu EnableImageSprites="False">
        </FilterMenu>
    </telerik:RadGrid>
    </form>
</body>
</html>

For this example i created a database called entity_test and one table with 3 columns (test1,test2,test3) on my Mysql 5.5 server

I would like to use RadControls cause i have worked with them for 3 years.
Thanks all.

1 Answer, 1 is accepted

Sort by
0
David
Top achievements
Rank 1
answered on 23 Jun 2012, 05:57 PM
OK i found the answer.
MasterTableView set AllowAutomaticUpdates=false even if i set in RadGrid to true, maybe MasterTableView should change that value if the parent (RadGrid) is changed.
Thank u all.
Tags
Grid
Asked by
David
Top achievements
Rank 1
Answers by
David
Top achievements
Rank 1
Share this question
or