简体   繁体   English

ASP.NET GridView抛出错误:“此控件禁用更新”

[英]ASP.NET GridView throwing error: “Update is disabled for this control”

I have the absolutely most simple setup imaginable. 我有一个可以想象的绝对最简单的设置。 A single table defined in an Entity model in ASP.net v4, the model is bound directly to a GridView with AutoGenerateEditButton enabled. 在ASP.net v4中的实体模型中定义的单个表,该模型直接绑定到启用了AutoGenerateEditButton的GridView。

However, each time I hit edit, then save, the page throws the error “Update is disabled for this control" for which I cannot find a solution. 但是,每次我点击编辑,然后保存,页面都会抛出错误“此控件已禁用更新”,我无法找到解决方案。

What is causing this error? 导致此错误的原因是什么? What can do to resolve it? 有什么办法可以解决它?

<%
<asp:GridView ID="MenuItemsGrid" runat="server"
    DataSourceID="gridDataSource"
    AutoGenerateEditButton="true"
    AutoGenerateColumns="true">  
</asp:GridView>  

<asp:EntityDataSource ID="gridDataSource" runat="server"
    ConnectionString="name=dataEntitiesModel"
    DefaultContainerName="dataEntities"
    EntitySetName="MenuItems" />
%>

Well, that was easy. 嗯,这很容易。 The data source needs to be enabled for insert/edit & delete. 需要启用数据源以进行插入/编辑和删除。

<%
<asp:EntityDataSource ID="gridDataSource" runat="server" 
    ConnectionString="name=dataEntitiesModel"
    DefaultContainerName="ASDKidsPlayEntities" EntitySetName="MenuItems" 
    EnableDelete="True" EnableInsert="True" EnableUpdate="True"/>
%>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM