本文介绍了在没有可显示的数据时显示空gridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
i有一个gridview,它从database.i获取数据可以搜索和添加数据。但是当你搜索不存在的记录时,我会在一个标签中显示该消息以上d gridview.but我的问题是..我需要显示页眉和页脚(通过页脚插入) 请帮我...我需要尽快完成 谢谢
i have a gridview whose getting data from an database.i can do search and addition of data.but when u search for an record not present i ll display the message in a label present above d gridview.but my prob is..i need to display the header and footer(insertion through footers) pls help me out...i need to do it soon thanks
推荐答案希望它有帮助 geekswithblogs/dotNETvinz/archive/2009/03/11/tiptrick-show-header - 网格视图 - 当没有数据.aspx
它会帮助你 It will Help u if (ds_login.Tables[0].Rows.Count == 0) { #region header with no record ds_login.Tables[0].Rows.Add(ds_login.Tables[0].NewRow()); GridView1.DataSource = ds_login; GridView1.DataBind(); int columncount = GridView1.Rows[0].Cells.Count; GridView1.Rows[0].Cells.Clear(); GridView1.Rows[0].Cells.Add(new TableCell()); GridView1.Rows[0].Cells[0].ColumnSpan = columncount; GridView1.Rows[0].Cells[0].Text = "No Records Found"; #endregion } else { GridView1.DataSource = ds_login; GridView1.DataBind(); }
你可以通过 you can do it by if (dt.Rows.Count > 0) { grid1.DataSource = dt; grid1.DataBind(); } else { dt.Rows.Add(dt.NewRow()); grid1.DataSource = dt; grid1.DataBind(); int totalcolums = grid1.Rows[0].Cells.Count; grid1.Rows[0].Cells.Clear(); grid1.Rows[0].Cells.Add(new TableCell()); grid1.Rows[0].Cells[0].ColumnSpan = totalcolums; grid1.Rows[0].Cells[0].Text = "No Data Found"; }
更多推荐
在没有可显示的数据时显示空gridview
发布评论