关闭

GridView没有数据显示表头

标签: dataset
853人阅读 评论(1) 收藏 举报

1" protected void NopassCotractBind()
    {

            ds = ct.GetNopassContract(CnnString, this.ouserinfo.fid);
            if (ds.Tables["Bill_Base"].Rows.Count > 0)
            {
                NopassContract.DataSource = ds.Tables["Bill_Base"].DefaultView;
                NopassContract.DataBind();

            }
            else
            {
                //NopassContract.DataSource = new DataTable () ;
                BindNoRecords(NopassContract, ds);
            }

            this.Count.Text = "总共有:" + ds.Tables["Bill_Base"].Rows.Count + "件;";       
                     
    }
    public void BindNoRecords(GridView gridView, DataSet ds)
    {
        if (ds.Tables[0].Rows.Count == 0)
        {
            ds.Tables[0].Rows.Add(ds.Tables[0].NewRow());
            gridView.DataSource = ds;
            gridView.DataBind();
            int columnCount = gridView.Rows[0].Cells.Count;
            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 = "没有数据信息";
            gridView.RowStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center;
        }
    } 
    

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:111118次
    • 积分:1703
    • 等级:
    • 排名:千里之外
    • 原创:56篇
    • 转载:7篇
    • 译文:0篇
    • 评论:34条
    最新评论