如何显示“未找到记录”如果gridview中没有记录,则在网格中 [英] How to display "No Records found" in the grid if record is not there in the gridview
本文介绍了如何显示“未找到记录”如果gridview中没有记录,则在网格中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有网格视图。
如何显示找不到记录在网格中如果gridview中没有记录而不是显示gridview代码..
Hi,
I have the gridview.
How to display "No Records found" in the grid if record is not there in the gridview instead of displaying gridview code..
推荐答案
你可以使用 EmptyDataText [ ^ ]属性或 EmptyDataTemplate [ ^ ] property。
这里有一个关于那个的例子
当GridView数据源中没有记录时显示自定义消息或图像 [ ^ ]
You can use EmptyDataText[^] property or EmptyDataTemplate[^] property.
Here an example about that
Display custom messages or images when there is no records in GridView Data Source[^]
< EmptyDataTemplate>
糟糕..!没有找到记录< / EmptyDataTemplate>
希望这对你有帮助。
<EmptyDataTemplate>
Oops..! No Records Found </EmptyDataTemplate>
Hope this will help you.
你好,
您可以尝试这样...
Hi,
You can try like this...
for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
{
for (int j = 0; j < dataGridView1.Columns.Count - 1; j++)
{
if (this.dataGridView1.Rows[i].Cells[j].Value.ToString() == "")
{
this.dataGridView1.Rows[i].Cells[j].Value = "No Records Found";
}
}
}
谢谢..
Thanks..
这篇关于如何显示“未找到记录”如果gridview中没有记录,则在网格中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文