Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 我可以显示asp.net网格中未找到的记录的消息吗?_C#_Asp.net_Visual Studio_Gridview - Fatal编程技术网

C# 我可以显示asp.net网格中未找到的记录的消息吗?

C# 我可以显示asp.net网格中未找到的记录的消息吗?,c#,asp.net,visual-studio,gridview,C#,Asp.net,Visual Studio,Gridview,我在asp.net中创建了一个网格视图,当没有记录时,网格不显示,我希望如果没有记录,网格必须显示,但必须有一条消息,记录未找到,gridview标题可用。我的意思是gridview必须在那里,但里面应该有一条消息,而不是行,record not found,我没有使用任何代码获取字符串中的数据,我只是使用了datasource,请帮助。gridview有一个EmptyDataText属性,如果没有找到记录,它将显示出来 EmptyDataText="Record Not Found" 如果要

我在asp.net中创建了一个网格视图,当没有记录时,网格不显示,我希望如果没有记录,网格必须显示,但必须有一条消息,记录未找到,gridview标题可用。我的意思是gridview必须在那里,但里面应该有一条消息,而不是行,record not found,我没有使用任何代码获取字符串中的数据,我只是使用了datasource,请帮助。

gridview
有一个
EmptyDataText
属性,如果没有找到记录,它将显示出来

EmptyDataText="Record Not Found"

如果要显示
GridView
的标题,然后,您可以使
数据表
具有
数据源
中的所有列,并添加一个空行,如果原始
数据源
不包含数据,则绑定该
数据表。

GridView
具有
EmptyDataText
属性,如果没有找到记录,则将显示该记录

EmptyDataText="Record Not Found"

如果要显示
GridView
的标题,则可以使
DataTable
包含
数据源中的所有列,并添加一个空行,并在原始
数据源不包含数据的情况下绑定该
DataTable

也可以显示自定义文本和格式

<asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSqlDataSource" 
        autogeneratecolumns="true"
        emptydatatext="No data in the data source."
        runat="server">

        <emptydatarowstyle backcolor="LightBlue"
          forecolor="Red"/>

      </asp:gridview>

您也可以显示自定义文本和格式

<asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSqlDataSource" 
        autogeneratecolumns="true"
        emptydatatext="No data in the data source."
        runat="server">

        <emptydatarowstyle backcolor="LightBlue"
          forecolor="Red"/>

      </asp:gridview>

试试这个

GridView1.EmptyDataText = "Record not found";
试试这个

GridView1.EmptyDataText = "Record not found";