private void RefreshDataSource() { if (Session["MessageTable"] != null) { dtMessages = (DataTable)Session["MessageTable"]; } InitializeDB(); QueryDBPlc(); GetLogs(); MessageLabel.DataSource = dtMessages; lblLastRefresh.Text = "Last Refreshed: " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString(); MessageLabel.DataBind(); }
private void InitMessages() { dtMessages = new DataTable(); DataColumn dcp = new DataColumn("ID", typeof(Int32)); DataColumn dc = new DataColumn("message"); DataColumn dcc = new DataColumn("command"); DataColumn dca = new DataColumn("address"); DataColumn dct = new DataColumn("timestamp", typeof(DateTime)); DataColumn dccalc = new DataColumn("parms"); dtMessages.Columns.Add(dcp); dtMessages.Columns.Add(dc); dtMessages.Columns.Add(dca); dtMessages.Columns.Add(dcc); dtMessages.Columns.Add(dct); dtMessages.Columns.Add(dccalc); DataColumn[] prim = new DataColumn[1] { dcp }; dtMessages.PrimaryKey = prim; dtMessages.Clear(); DataRow dr = dtMessages.NewRow(); dr["ID"] = 0; dr["message"] = "Initialised"; dr["timestamp"] = DateTime.Now; dtMessages.Rows.Add(dr); DataView dv = dtMessages.DefaultView; dv.Sort = "ID desc"; MessageLabel.DataSource = dv; MessageLabel.DataBind(); Session["MessageTable"] = dtMessages; QueryPlc(); }