这是问题的屏幕截图:
http://screencast.com/t/ZG2NQWjxYFLh
我正在尝试使用 DevExpress 数据网格通过 Linq 向数据库添加一条记录。提交数据的时候报错:
LinqDataSource 'linqDsLocales' 没有要插入的值。检查“值”字典是否包含值。
这就是我的 LinqDataSource 的样子:
<asp:LinqDataSource ID="linqDsLocales" runat="server" ContextTypeName="MyCompany.MyObject.DataDataContext" TableName="Locales" EnableInsert="True" EnableUpdate="True" EnableDelete="True" />
这是网格:
<dx:ASPxGridView ID="gridLocales" runat="server" AutoGenerateColumns="False" DataSourceID="linqDsLocales" KeyFieldName="LocaleID">
<Columns>
<dx:GridViewCommandColumn ShowInCustomizationForm="True" VisibleIndex="0">
<EditButton Visible="True" />
<NewButton Visible="True" />
<DeleteButton Visible="True" />
</dx:GridViewCommandColumn>
<dx:GridViewDataTextColumn FieldName="LocaleID" ReadOnly="True" VisibleIndex="1">
<EditFormSettings Visible="False" />
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="Name" VisibleIndex="2"/>
<dx:GridViewDataTextColumn FieldName="Description" VisibleIndex="3"/>
</Columns>
<Settings ShowFilterRow="True" />
<Templates>
<EditForm>
<dx:ASPxPageControl ID="tabLocaleEditController" runat="server" ActiveTabIndex="0" Width="100%">
<TabPages>
<dx:TabPage Text="Locale Information">
<ContentCollection>
<dx:ContentControl runat="server">
<dx:ASPxGridViewTemplateReplacement ID="localeEditors" ReplacementType="EditFormEditors" runat="server" />
</dx:ContentControl>
</ContentCollection>
</dx:TabPage>
<dx:TabPage Text="Role Assigment">
<ContentCollection>
<dx:ContentControl runat="server">
<dx:ASPxCheckBoxList ID="cbListRoles" runat="server" ValueType="System.String" DataSourceID="linqDsRoles" TextField="RoleName" ValueField="RoleID" OnDataBound="cbListRoles_OnDataBound" />
</dx:ContentControl>
</ContentCollection>
</dx:TabPage>
</TabPages>
</dx:ASPxPageControl>
<div style="text-align: right; padding: 2px 2px 2px 2px">
<dx:ASPxGridViewTemplateReplacement ID="UpdateButton" ReplacementType="EditFormUpdateButton" runat="server" />
<dx:ASPxGridViewTemplateReplacement ID="CancelButton" ReplacementType="EditFormCancelButton" runat="server" />
</div>
</EditForm>
</Templates>
</dx:ASPxGridView>
任何人都可以对此有所了解吗?