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
查看全文
相关阅读:
等差子序列(sequence)
威士忌(whiskey)
图论:2-SAT模板
poj2723-Get Luffy Out
acdream1412:2-3 trees 组合数dp
hdu3849-By Recognizing These Guys, We Find Social Networks Useful:双连通分量
ZOJ2317-Nice Patterns Strike Back:矩阵快速幂,高精度
ZOJ3519-Beautiful People:最长上升子序列的变形
hdu2460-Network:边的双连通分量
hdu4405:概率dp
原文地址:https://www.cnblogs.com/hambywu/p/1172290.html
最新文章
Rock-Paper-Scissors Tournament[HDU1148]
Pick-up sticks[HDU1147]
计算几何算法合集
#3316. baka
#3315. fullcombo
#3314. constructive
#3194. 去月球
#3160. 序列计数(count)
#3328. 开箱子(unboxing)
#3124. 开锁(unlock)
热门文章
#2485. 聚会(kamp)
#2488. 象棋游戏(topovi)
全连
疫情控制 blockade
书架 bookshelf
树(tree)
bzoj3786: 星系探索
朗格拉日计数(counter)
演艺
ZCC loves cube(cube)
Copyright © 2011-2022 走看看