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
查看全文
相关阅读:
计算机知识
试题:论需求分析方法及应用
试题:论信息系统开发方法及应用
爬虫数据存储——安装docker和ElasticSearch(基于Centos7)
go并发版爬虫
go单任务版爬虫
可变类型与不可变类型
基本数据类型内置方法
@submit.native.prevent作用
获取当月第一天,今天的日期的方法
原文地址:https://www.cnblogs.com/hambywu/p/1172290.html
最新文章
Scala学习 函数式对象
Scala学习 基本类型与操作
Scala学习 类与对象
Scala入门(二)
httpie 工具学习
Scala学习笔记 -- 入门(一)
Scala学习笔记(一) -- 简介
Akka 简介
sklearn datasets数据集
sklearn
热门文章
mnist.npz的使用
phone
imdb.npz 下载链接,拒绝做生意,开源精神
matplotlib 经验
设置pip 的源
tensorflow2 基础
Django 更改时区
验证码识别
编程语言与python介绍
计算机知识详解
Copyright © 2011-2022 走看看