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
查看全文
相关阅读:
使用Silverlight 实现工作流流程定义
中国国内航线信息的可视化
笨办法学R编程(5)
笨办法学R编程(4)
笨办法学R编程(3)
香山杯部分WP
PWNABLE 3x17
PWNABLE dubblesort
PWNABLE applestore
pyc文件修复出题经历
原文地址:https://www.cnblogs.com/hambywu/p/1172290.html
最新文章
[iOS]学习笔记5(CATransform3DCube)
[iOS]学习笔记4(一些问题)
cygwin sshd服务启动不了的解决方案(转)
小P环境使用
用栈进行进制转换
二叉树的插入,递归遍历和深度节点数
图的深搜和广搜
栈的应用迷宫
深入理解include预编译原理
栈的一些应用
热门文章
12 Ways to Become a Better Programmer
kmp matching
8 ways to be a better programmer in 6 minutes.
手机、未来、饭碗
把软件做成艺术品
软件交互设计原则
找到最重要的知识
“智能”的随想
软件也是仿生学
从人脑到搜索引擎的畅想
Copyright © 2011-2022 走看看