zoukankan
html css js c++ java
当DataSet为空时也显示GridView的表头
/**/
/**/
/**/
///
<summary>
///
当DataSet为空时也显示GridView的表头
///
</summary>
///
<param name="gridView">
所要绑定的GridView
</param>
///
<param name="ds">
所要绑定的数据集
</param>
///
<returns>
void
</returns>
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;
}
}
注:其他数据源 如 dataview datatable也类似的写法
if
(dv.Count
==
0
)
{
dv.Table.Rows.Add(dv.Table.NewRow());
this
.Gv_Storage.DataSource
=
dv;
this
.Gv_Storage.DataBind();
int
count
=
this
.Gv_Storage.Rows[
0
].Cells.Count;
Gv_Storage.Rows[
0
].Cells.Clear();
Gv_Storage.Rows[
0
].Cells.Add(
new
TableCell());
Gv_Storage.Rows[
0
].Cells[
0
].ColumnSpan
=
count;
Gv_Storage.Rows[
0
].Cells[
0
].Text
=
"
没有记录
"
;
Gv_Storage.RowStyle.HorizontalAlign
=
System.Web.UI.WebControls.HorizontalAlign.Center;
}
else
{
this
.Gv_Storage.DataSource
=
dv;
this
.Gv_Storage.DataBind();
}
我的淘宝店:
http://hamby.taobao.com
查看全文
相关阅读:
什么是索引?怎么创建索引?索引的使用原则?
Cookie和Session的区别
HashMap、Hashtable、ConcurrentHashMap的原理与区别
vxlogcfg vxlogcfg – 修改统一日志记录配置设置
磁盘阵列RAID介绍及计算公式
二叉树的最近公共祖先 递归
LRU 缓存机制
从前序与中序遍历序列构造二叉树 递归
MySQL 数据结构常用命令
Node.Js 搭建简单的 EggJs 示例项目
原文地址:https://www.cnblogs.com/hambywu/p/1172290.html
最新文章
[antdv: DatePicker] `value` provides invalidate moment time. If you want to set empty value, use `null` instead.
ant design vue 日期选择器只选择年份
el-upload组件限制上传个数
vue封装组件发布到npm
element表格实现复选框单选
接口自动化中requests请求处理cookies和token鉴权的方法
Python 继承知识点总结
获取appPackage和appActivity的方法
APP自动化测试环境搭建
jenkins安装方式和持续集成
热门文章
pytest 常用插件安装
写Bug时,需要注意的几点 02
重构改善既有代码的设计---笔记
ExcelDataReader插件的使用
jvm GC算法和种类
JVM加载class文件的原理机制
线程状态,BLOCKED和WAITING有什么区别
什么是面向对象?
关于java中的hashcode和equals方法原理
.ArrayList是如何实现的,ArrayList和LinkedList的区别?ArrayList如何实现扩容?
Copyright © 2011-2022 走看看