Gridview EmptyDataText=“无数据” - 如何为文本添加样式“无数据”

发布于 2024-08-09 00:42:30 字数 181 浏览 10 评论 0原文

我的 C# 程序中有一个 gridview 控件,并且刚刚添加了一个“EmptyDataText”控件,如果没有找到记录,该控件(如您所知)会显示一条消息。当我在设计中查看此页面时,“未找到数据”文本为 times new roman 并且没有样式。是否可以将此文本设为 Verdana 并将文本居中而不是放在左侧?

期待您的回复!

I have a gridview control in my C# program and have just added an 'EmptyDataText' control that (as you know) displays a message if no records were found. When I view this page in design, the 'No data found' text is in times new roman and no style. Is it possible to make this text Verdana and also centre the text rather than it being on the left?

Look forward to your reply!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

叶落知秋 2024-08-16 00:42:30

这已经很晚了,但是上面的答案都没有提到这一点:根据官方文档 您可以使用 EmptyDataRowStyle 设置绑定 GridView 控件时呈现的空数据行的外观到不包含任何记录的数据源。

  <asp:gridview id="MyGridView" 
    emptydatatext="No data found in source"
    autogeneratecolumns="true"
    runat="server">
    
    <emptydatarowstyle backcolor="LightBlue"
      forecolor="Red"/>  <!-- modify this to whatever style you want -->
  </asp:gridview>

This is quite late, but none of the above answers mentioned this: according to the official documentation you can use EmptyDataRowStyle to set the appearance of the empty data row rendered when a GridView control is bound to a data source that does not contain any records.

  <asp:gridview id="MyGridView" 
    emptydatatext="No data found in source"
    autogeneratecolumns="true"
    runat="server">
    
    <emptydatarowstyle backcolor="LightBlue"
      forecolor="Red"/>  <!-- modify this to whatever style you want -->
  </asp:gridview>
笨笨の傻瓜 2024-08-16 00:42:30

您可以将 EmptyDataRowStyle-CssClass 属性设置为您要使用的 css 类。

<asp:GridView EmptyDataRowStyle-CssClass="your-css-class" />

You can set EmptyDataRowStyle-CssClass attribute to the css class you want to use.

<asp:GridView EmptyDataRowStyle-CssClass="your-css-class" />
与酒说心事 2024-08-16 00:42:30

在这里你有一些东西:
http://msdn.microsoft。 com/en-us/library/system.web.ui.webcontrols.gridview.emptydatatext.aspx

或者您可以尝试以下操作:
EmptyDataText =

未找到数据

" -> 并调整您需要的样式。

Here you have something:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.emptydatatext.aspx

Or you can try this:
EmptyDataText = <div style=\"width:100%;color:red;\">No data found </div>" -> and adjusting the style you need.

澉约 2024-08-16 00:42:30

您还可以在 gridview 中使用 EmptyDateTemplate

<EmptyDataTemplate>
        <label style="color:Red;font-weight:bold">No records found !</label>
        </EmptyDataTemplate>

You can also use EmptyDateTemplate in your gridview

<EmptyDataTemplate>
        <label style="color:Red;font-weight:bold">No records found !</label>
        </EmptyDataTemplate>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文