我有一个与数据源绑定的数据网格。我设置isReadOnly =“False”属性进行编辑。当我点击单元格然后发生异常。 Xaml代码: -
<DataGrid Name="dataGrid1" AutoGenerateColumns="True" IsReadOnly="False">
<DataGrid.Columns>
<DataGridTextColumn Header="Fee Head" Width="250" Binding="{Binding feename}" IsReadOnly="False"/>
<DataGridTextColumn Header="Amount(Rs.)" Width="250" Binding="{Binding NewAmount}"/>
<DataGridTextColumn Visibility="Hidden" Header="cnt" Width="10" Binding="{Binding id}"/>
</DataGrid.Columns>
</DataGrid>
.cs代码: -
var obje = (from tab in cd.FeeDeclarationDetails
join tab2 in cd.AccountHeadDBs on tab.AccountHeaddbid equals tab2.ID
where tab.AccountHeaddbid == tab2.ID
select new { feename = tab2.Head_Name, tab.NewAmount, cnt = (cd.FeeDeclarationDetails.Where(A => A.AccountHeaddbid == 1 && A.FeeDeclarationID == 1).ToList().Count > 0 ? cd.FeeDeclarationDetails.Where(A => A.AccountHeaddbid == 1 && A.FeeDeclarationID == 1).ToList().Count : 0) }).ToList();
dataGrid1.ItemsSource = obje;
我正在使用linq2sql。例外情况是: - TwoWay或OneWayToSource绑定无法在类型为'&lt;&gt; f__AnonymousType6 3[System.String,System.Nullable
1 [System.Int32],System.Int32]'的只读属性'NewAmount'上工作。所以怎么能我解决了这个问题。
答案 0 :(得分:0)
您的属性&#39;类型FeeDeclarationDetails的NewAmount&#39;似乎是只读属性..确保它有一个setter ..