private void BindGridView() { CommonDao<Safezhuan> newmgr = new CommonDao<Safezhuan>(); DataTable dt = new DataTable(); dt = newmgr.FindDataTableByCondition(""); if (dt.Rows.Count == 0) { dt.Rows.Add(dt.NewRow()); GridViewEmployee.DataSource = dt; GridViewEmployee.DataBind(); int columnCount = dt.Columns.Count; GridViewEmployee.Rows[0].Cells.Clear(); GridViewEmployee.Rows[0].Cells.Add(new TableCell()); GridViewEmployee.Rows[0].Cells[0].ColumnSpan = columnCount + 1; GridViewEmployee.Rows[0].Cells[0].Text = "没有记录"; GridViewEmployee.Rows[0].Cells[0].Style.Add("text-align", "center"); } else { GridViewEmployee.DataSource = dt; GridViewEmployee.DataBind(); } }