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
查看全文
相关阅读:
BackgroundWorker
Devexpress 10
Winform常用控件的使用(一)
Composite UI Application Block(CAB)
HTML CSS简单总结
C# JSON字符串序列化与反序列化常见模型举例
HTML 调用iscroll.js主要事项
HTML5 Socket通信
Webservice加上SoapHeader验证方式
动态调用Webservice 支持Soapheader身份验证(转)
原文地址:https://www.cnblogs.com/hambywu/p/1172290.html
最新文章
插入排序和归并排序
Java并发编程的艺术(一)
设计模式(四)—— 单例模式
设计模式(三)—— 外观模式
二分搜索
【ACM】懒省事的小明
Angular JS ng-model对<select>标签无效的情况
Angular JS ng-repeat 报错 Error: [ngRepeat:dupes]
【ACM】无聊的小明
Angular JS 1.X 接口拿不到 http post 请求的数据
热门文章
冷热数据分离思路
【ACM】蛇形填数
【ACM】会场安排问题
PHP Redis锁
DevExpress.XtraGrid.Views.Grid.GridView
C# Socket
微信公众号开发
EventArgs
消息机制模型
.net2.0 Thread 多线程
Copyright © 2011-2022 走看看