private void DrawUserTable() { /* Init Table with Headers */ TableRow header = new TableRow(); TableHeaderCell thc1 = new TableHeaderCell(); TableHeaderCell thc2 = new TableHeaderCell(); TableHeaderCell thc3 = new TableHeaderCell(); TableHeaderCell thc4 = new TableHeaderCell(); TableHeaderCell thc5 = new TableHeaderCell(); thc1.Text = "Username"; thc2.Text = "Email"; thc3.Text = "Role"; thc4.Text = "Last Login"; header.Cells.Add(thc1); header.Cells.Add(thc2); header.Cells.Add(thc3); header.Cells.Add(thc4); header.Cells.Add(thc5); UserTable.Rows.Add(header); /* Add Users to Table */ AdminUtilities au = new AdminUtilities(); List <UserContainer> list = au.getAllUsers(); int rows = list.Count; int count = 0; foreach (UserContainer user in list) { TableCell tc1 = new TableCell(); TableCell tc2 = new TableCell(); TableCell tc3 = new TableCell(); TableCell tc4 = new TableCell(); TableCell tc5 = new TableCell(); if (list != null) { if (list[count] != null) { LinkButton link = new LinkButton(); link.Text = user.Username; link.ID = "Username" + count; link.Click += User_Click; tc1.Controls.Add(link); tc2.Text = user.Email; foreach (String role in user.RoleStrings()) { if (role != user.RoleStrings().Last()) { tc3.Text = tc3.Text + role + ", "; } else { tc3.Text = tc3.Text + role; } } tc4.Text = user.LastLoginDate.ToString(); LinkButton link2 = new LinkButton(); link2.Text = "edit"; link2.ID = "Edit" + count; link2.Click += User_Click; tc5.Controls.Add(link2); } } count++; TableRow tr = new TableRow(); tr.Cells.Add(tc1); tr.Cells.Add(tc2); tr.Cells.Add(tc3); tr.Cells.Add(tc4); tr.Cells.Add(tc5); UserTable.Rows.Add(tr); } }