【发布时间】:2020-12-14 06:55:28
【问题描述】:
这是我的分析模型类
public partial class analys
{
public int id { get; set; }
public string name { get; set; }
public int price { get; set; }
public bool Type_qualitatif { get; set; }
public bool Type_quantitatif { get; set; }
public System.DateTime create_at { get; set; }
public System.DateTime update_at { get; set; }
public int sectionId { get; set; }
public virtual section section { get; set; }
}
}
我创建了一个列表框,它显示复选框为项目,每个项目的内容是一个分析的名称。
所以我试图检查复选框的内容并将它们保存在一个列表中,代码如下
foreach ( CheckBox item in _biochimieExam.BiochimieExamsItemsControl.Items )
{
if(item.IsChecked == true)
{
// String exam = item.Content.ToString();
SelctedItems.Add(item.Content.ToString());
}
}
foreach(String item in SelctedItems)
{
BchExamsList.Add(new analys
{
name = item
}) ;
}
但我遇到了一个无效的强制转换异常无法在“System.Windows.Controls.CheckBox”类型中强制转换类型为“System.Data.Entity.DynamicProxies.analys_F69488E20B133B223573E1D5931B83214F85574493596933EB8BFDBD5F513C59”的对象。我试图解决。但是我失败了。
我需要一些帮助。谢谢。
【问题讨论】:
标签: c# checkbox casting system.data