如何向用户发送“未找到记录"的消息;当数据集为空时在datagridview控件中 [英] How To Give message to user that "No Record found" in datagridview control when dataset is empty

查看:92
本文介绍了如何向用户发送“未找到记录"的消息;当数据集为空时在datagridview控件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友,
使用桌面应用程序时,datagridview控件出现问题.
我使用数据集绑定此datagridview.如果数据集不为空,则会在datagridview中显示所有记录.
假设数据集为空,我想向用户未找到记录"发送消息,并将其显示在datagridview的单行中.

请帮帮我.

在此先感谢..



Randeep Chauhan ...

Hi Friends,
I have a problem in datagridview control while working with desktop application.
I use data set to bind this datagridview.If dataset is not empty it display all records in datagridview.
Suppose Data set is empty,I want give message to the user "No Record founds" and display it in the single row of datagridview.

Please Help me.

Thanks in Advance..



Randeep Chauhan...

推荐答案

具有EmptyDataText的DataGridView组件属性-Windows窗体应用程序 [^ ]


尝试执行以下操作.基本上,dataset.fill返回查询返回的行数

Try following.Basically dataset.fill returns number of rows returned by your query

int rows = DatasetName.fill(dataadapter,"tablename");
if(rows <= 0)
{
  //Add a row to data grid and display your msg
}
else
{
  //do what needs to be done
}


<EmptyDataTemplate>
                                                <table width="100%">
                                                    <tr>
                                                        <td class="ob_gNRM" style="height: 40px; text-align: center">
                                                            There are no records available.
                                                        </td>
                                                    </tr>
                                                </table>
                                            </EmptyDataTemplate>


这篇关于如何向用户发送“未找到记录"的消息;当数据集为空时在datagridview控件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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