使用LINQ将数据库中所有符合条件的数据读出,并赋值给TextArea1控件,要求显示一条记录一换行,如何实现?
- C# code
var DR = from a in SQL.PSNs where a.Qno == "Q1452654" select new { a.SN }; foreach (var abc in DR) { TextArea1.Value = abc + "\r\n"; }
------解决方案--------------------------------------------------------
TextArea1.Value = abc + "\r\n";
=》
TextArea1.Value += abc.SN + "\r\n";
------解决方案--------------------------------------------------------
var DR = from a in SQL.PSNs
where a.Qno == "Q1452654"
select a.SN;
TextArea1.Value = string.Join("\r\n",DR.ToArray())
------解决方案--------------------------------------------------------
- C# code
var DR = from a in SQL.PSNs where a.Qno == "Q1452654" select a.SN;TextArea1.Value = string.Join("<br />",DR.ToArray());
------解决方案--------------------------------------------------------
TextArea1.Value += (abc + "\r\n");