国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

當(dāng)GridView數(shù)據(jù)為空時(shí),解決表格不顯示的問題

2019-11-14 09:34:15
字體:
供稿:網(wǎng)友

 namespace  XXX.COM{   public class ComClass    {

PRivate static string EmptyText = "沒有記錄";

        /// <summary>        /// 綁定數(shù)據(jù)到GridView,當(dāng)表格數(shù)據(jù)為空時(shí)顯示表頭        /// </summary>        /// <param name="gridview"></param>        /// <param name="table"></param>        public static void GridViewDataBind(GridView gridview, DataTable table)        {            //記錄為空重新構(gòu)造Gridview            if (table.Rows.Count == 0)            {                table = table.Clone();                table.Rows.Add(table.NewRow());                gridview.DataSource = table;                gridview.DataBind();                int columnCount = table.Columns.Count;                     //得到列數(shù)                gridview.Rows[0].Cells.Clear();                             //清除所有列                gridview.Rows[0].Cells.Add(new TableCell());              //添加新列                gridview.Rows[0].Cells[0].ColumnSpan = columnCount;          //新行寬度                gridview.Rows[0].Cells[0].Text = EmptyText;                gridview.Rows[0].Cells[0].Style.Add("text-align", "center");            }            else            {                //數(shù)據(jù)不為空直接綁定                gridview.DataSource = table;                gridview.DataBind();            }

        }

    }}


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 阿鲁科尔沁旗| 石河子市| 阜平县| 浮山县| 武汉市| 平潭县| 永顺县| 镇赉县| 台江县| 永兴县| 浑源县| 玉树县| 会昌县| 清水县| 新昌县| 小金县| 洞口县| 仁化县| 万安县| 湟源县| 宁陵县| 闻喜县| 吉安市| 嘉荫县| 宿松县| 富平县| 安溪县| 贡觉县| 桐梓县| 平和县| 雷州市| 洱源县| 万载县| 连江县| 天台县| 大田县| 扎赉特旗| 临猗县| 西林县| 那坡县| 屯留县|