定义一个变量,将多表查询的结果添加到变量,再把变量里多表查询的结果绑定到listview控件
,下面是代码
TabelDataContext dc = new TabelDataContext();
var query = from s in dc.Employee
//from d in dc.Department
where Convert.ToInt32(s.DID) == 2
select new
{
ID = s.eID,
Name = s.eName,
Sex=s.eSex,
Birthday=s.eBirthday,
};
// this.listView1.Items.Add(query);
foreach (var result in query)
{
var u = result;
ListViewItem lvi = new ListViewItem();
lvi.Tag = query;
lvi.Text = "编号:" + u.ID + "名称:" + u.Name;
lvi.Name = u.ID;
lvi.SubItems[0] = u.ID;//想把查询结果的字段赋值到集里,显示无法进行转换
lvi.ImageIndex = 0;
this.listView1.Items.Add(lvi);
现在想把listview选中的项赋值到textbox里面去,但查询的结果不是一张表里的内容了,那怎么将query里的字段绑定到textbox中以达到实现修改的功能
}