0

我有 gridview 从 sql server 获取数据表。当数据表没有行时,我编写了一个函数来绑定来自单独源的gridview,该函数将新行添加到gridview 还合并所有列并显示错误消息“未找到结果”,但这不起作用所有列正在显示照原样。下面给出绑定空网格的函数

   private void ShowNoResultFound(DataTable source, GridView gv, bool footerStatus)
   {
       source.Rows.Add(source.NewRow());
       gv.DataSource = source;

       gv.ShowFooter = footerStatus;

       int columnsCount = gv.Columns.Count;
       gv.DataBind();
       gv.Rows[0].Cells.Clear();
       gv.Rows[0].Cells.Add(new TableCell());
       gv.Rows[0].Cells[0].ColumnSpan = columnsCount;


       gv.Rows[0].Cells[0].HorizontalAlign = HorizontalAlign.Center;
       gv.Rows[0].Cells[0].ForeColor = System.Drawing.Color.Red;
       gv.Rows[0].Cells[0].Font.Bold = true;

       gv.Rows[0].Cells[0].Text = "NO RESULT FOUND!";

   }
4

1 回答 1

1

设置 EmptyDataText="未找到结果!!!" Grdi View 的属性

于 2013-06-26T12:51:21.200 回答