Gridview EmptyDataText=“无数据” - 如何为文本添加样式“无数据”
我的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这已经很晚了,但是上面的答案都没有提到这一点:根据官方文档 您可以使用
EmptyDataRowStyle
设置绑定 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.您可以将 EmptyDataRowStyle-CssClass 属性设置为您要使用的 css 类。
You can set EmptyDataRowStyle-CssClass attribute to the css class you want to use.
在这里你有一些东西:
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.您还可以在 gridview 中使用 EmptyDateTemplate
You can also use EmptyDateTemplate in your gridview