在没有可显示的数据时显示空gridview

编程入门 行业动态 更新时间:2024-10-26 03:23:07
本文介绍了在没有可显示的数据时显示空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

本文发布于:2023-11-08 08:02:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1568809.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据   gridview

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!