I display an empty data set in my gridview by manipulating the gridview to show the headers and a row displaying only No Records Found. Here is the code for that:
if (EQTable.DefaultView.Count == 0)//if filtered data is empty, make sure to show header { EQTable.Rows.Clear(); EQTable.Rows.Add(EQTable.NewRow()); TimeStampGridView.DataSource = EQTable; TimeStampGridView.DataBind();int colNum = TimeStampGridView.Columns.Count; TimeStampGridView.Rows[0].Cells.Clear(); TimeStampGridView.Rows[0].Cells.Add(new TableCell()); TimeStampGridView.Rows[0].Cells[0].ColumnSpan = colNum; TimeStampGridView.Rows[0].Cells[0].Text ="No Records Found."; }
When the timer Tick event goes off is should only check if new data is present by checking the last write time to an xml file. If no new data is present is just returns, On the return, it updates the gridview to show all the cells of the empty row and erases the No Records Found text. Here is the code:
protected void UpdateTimer_Tick(object sender, EventArgs e) {string oldTime = Lb_LastRun.Text;string newTime = GetLastRunTime();if (oldTime != newTime)//doesn't go in for an empty row, but messes up cells of gridview { Lb_LastRun.Text = newTime; EnableExtractorCols(); LoadGrid(); DisableExtractorCols(); } }
Anyone know what I'm doing wrong here? Thanks for the help!!!
I got around this problem by changing the timer tick code:
protected void UpdateTimer_Tick(object sender, EventArgs e)
{
string oldTime = Lb_LastRun.Text;
string newTime = GetLastRunTime();
if (oldTime != newTime)
{
Lb_LastRun.Text = newTime;
EnableExtractorCols();
LoadGrid();
DisableExtractorCols();
}
if (TimeStampGridView.Rows.Count > 0)
{
Label EQLabel = (Label)TimeStampGridView.Rows[0].FindControl("Label1");
if (EQLabel.Text == "")//check for empty row, this is important for displaying headers only on a status filter
{
int colNum = TimeStampGridView.Columns.Count;
TimeStampGridView.Rows[0].Cells.Clear();
TimeStampGridView.Rows[0].Cells.Add(new TableCell());
TimeStampGridView.Rows[0].Cells[0].ColumnSpan = colNum;
TimeStampGridView.Rows[0].Cells[0].Text = "No Equipment Found.";
}
}
}
is there another way to stop this updating?
No comments:
Post a Comment