【问题标题】:DataGrid want to display NO RECORDSDataGrid 想要显示 NO RECORDS
【发布时间】:2011-09-06 15:42:24
【问题描述】:

在我的应用程序中,我正在使用 DataGrid,我将数据集绑定到该 DataGrid。因此,如果数据集记录为零,我想在我的 DataGrid 中显示“NO ReCORDS FOUND”。

提前致谢。

【问题讨论】:

  • 我们可以查看您当前的代码吗?

标签: asp.net gridview datagrid


【解决方案1】:

DataGrid 中没有 EmptyDataText 属性,因此在您的代码隐藏中执行类似的操作

if (dgTest.Items.Count == 0)
{
    lblEmpty.Visible = true;
    lblEmpty.Text = "Empty";
}

其中dgTestDataGrid 的ID,lblEmpty 是占位符标签。

【讨论】:

  • 最好有。 if (dgTest.Items.Count
【解决方案2】:

您也有 GridView 标签,因此对于 GridView,您可以将其 EmptyDataText 属性设置为 "No records found"DataGrid 有点复杂。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-10-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-28
    • 2021-07-30
    相关资源
    最近更新 更多