GridView中的数据源 [英] Datasource in gridview

查看:78
本文介绍了GridView中的数据源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何查找数据源是否绑定到网格?

如果数据源没有记录..

它必须显示消息..

How to find if the data source is binded to the grid or not?

If data source doesn''t have the records..

It has to show message..
Can anyone can post me some code for this..?

推荐答案

如果您的数据源没有数据,则根据数据表的行数显示消息.

在将数据源绑定到网格之前,请检查数据表中是否有行.如果有任何行,则将其绑定,否则显示消息.
例如:
If your datasource does not have data then show the message based on the datatable row count.

Before binding the datasource to grid, check for rows in the datatable. If there is any row then bind it or else show the message.
Ex:
// Sample snippet in C# - it was easy and quick for me to write
if(mygridsDataSourceTable.Rows.Count > 0)
{
  // BindGrid
}
else
{
  // Show message that there is no record. 
  // Show grid with Emptytextmessage
  // do whatever you like!
}


这篇关于GridView中的数据源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆