I'm trying to load Data from database to RichTextBox (as image shows) in my c# windows form Project using Linq.
I don't know if I am doing it right, because the data is not loading to the RichTextBox. Please help.
This is how I'am trying to do it:
string idNr = txtIdcardNr.Text.Trim();
var CheckIfIdCardExist = (from u in db.Customer
where u.IdentityCardNr == idNr
select u).FirstOrDefault();
if(CheckIfIdCardExist != null)
{
String template =
@"Date\t\t{0}
Notes\t\t{1}
Staff\t\t{2}
*********\t\t{3}";
var notes = (from u in db.CustomerNotes
join em in db.Employee on u.StaffId equals em.EmployeeId
where u.CustomerId == CheckIfIdCardExist.CustomerId
select new {
Date = u.NoteDate,
notes = u.Notes,
employee = em.FirstName + " " + em.LastName
}).ToList();
foreach(var n in notes)
{
richTextBox1.Text = string.Format(template, n.Date, n.notes, n.employee);
}

richTextBox1.Text =obviously this line is going bring you unstuck regardless of any other problem, you'll just be adding the last note