private void LoadSentItems() { jobSys = SmsFactory.getSystem("eJobs"); //get unset list from db DataTable MessageList = jobSys.getRecord(); //convert datasource to list List <DataRow> Messagelist = MessageList.AsEnumerable().ToList(); tableLayoutPanel1.RowCount = 0; tableLayoutPanel1.Controls.Clear(); foreach (DataRow row in MessageList.Rows) { string notificationID = row["NotficationId"].ToString(); string ClientName = row["ClientName"].ToString(); string message = row["Message"].ToString(); string Schedule = row["DTlog"].ToString(); string msgStatus = row["Status"].ToString(); SMSinbox msgbox = new SMSinbox(); msgbox.setContent(Int32.Parse(notificationID), ClientName, message, Schedule, msgStatus); tableLayoutPanel1.RowCount = tableLayoutPanel1.RowCount + 1; tableLayoutPanel1.Controls.Add(msgbox); } }