asp.net GridView 后台绑定数据无数据显示表头及没有数据一行

 IList<类名> lists = 类名Manager.GetAll();

var listgrid = (from v in lists
                                                where v.State == state
                                                select v).Skip(pageindex * pagesize).Take(pagesize);


               //没有数据的时候,GridView添加一条新行,内容为没有数据

                if (listgrid.Count() == 0)

                {
                    int cols = this.gvLists.Columns.Count;
                    this.gvLists.Rows[0].Cells.Clear();
                    this.gvLists.Rows[0].Cells.Add(new TableCell());
                    this.gvLists.Rows[0].Cells[0].ColumnSpan = cols;
                    this.gvLists.Rows[0].Cells[0].Text = "没有数据";
                    this.gvLists.Rows[0].Cells[0].Style.Add("text-align", "center");
                }

你可能感兴趣的:(知识收集)