protected void EmailView_SelectedIndexChanged(object sender, EventArgs e) { int emailIdentifier = Convert.ToInt32(EmailView.SelectedRow.Cells[1].Text); NewBDcon(); dbcon.StudentTables.Load(); dbcon.UserTables.Load(); dbcon.AdvisorTables.Load(); dbcon.AppointmentTables.Load(); dbcon.MessagesTables.Load(); var emails = from email in dbcon.MessagesTables.Local where email.EmailID == emailIdentifier select email; var formatSingleEmail = from email in emails select new { EmailID = email.EmailID, From = email.EmailFrom, Date = email.EmailDate.ToShortDateString() + " " + email.EmailDate.Add(email.EmailTime).ToString("hh:mm tt"), Message = email.EmailText }; DetailEmailView.DataSource = formatSingleEmail; DetailEmailView.DataBind(); }
protected void Fill_Emails() { string userName = User.Identity.Name; NewBDcon(); dbcon.StudentTables.Load(); dbcon.UserTables.Load(); dbcon.AdvisorTables.Load(); dbcon.AppointmentTables.Load(); dbcon.MessagesTables.Load(); var emails = from email in dbcon.MessagesTables.Local join user in dbcon.UserTables on email.EmailTo equals user.UserEmail where user.UserName == userName select email; var formatSingleEmail = from email in emails select new { EmailID = email.EmailID, From = email.EmailFrom, Date = email.EmailDate.ToShortDateString() + " " + email.EmailDate.Add(email.EmailTime).ToString("hh:mm tt"), Message = email.EmailText }; var formatEmails = from email in emails select new { emailID = email.EmailID, emailDate = email.EmailDate.ToShortDateString(), emailTime = email.EmailDate.Add(email.EmailTime).ToString("hh:mm tt"), From = email.EmailFrom }; DetailEmailView.DataSource = formatSingleEmail; DetailEmailView.DataBind(); EmailView.DataSource = formatEmails; EmailView.DataBind(); if (EmailView.Rows.Count != 0) { EmailView.SelectRow(0); } }