问题描述
在表格的td中的HTML中,您可以通过在单词之间使用<BR>
来中断文本.这也适用于TemplateItem的HeaderText,而不适用于BoundField的HeaderText.如何拆分BoundField的标题文本.
In HTML in the td of a table you can break text by using <BR>
between the words. This also works in the HeaderText of a TemplateItem but not the HeaderText of a BoundField. How do I break up the Header text of a BoundField.
推荐答案
在BoundField
<asp:BoundField DataField="SomeDataField"
HeaderText="SomeHeader<br />(OtherData)"
HtmlEncode="false" />
BoundField.HtmlEncode
默认情况下为true,这意味着如果在文本中添加HTML,则会对其进行编码.
如果将HtmlEncode设置为false,则不会对文本进行编码,并且br将按预期工作.不幸的是,不可能只为标题文本指定此名称,这也会影响单元格的内容.
BoundField.HtmlEncode
is true by default which means that if HTML is added in the text it will be encoded.
If HtmlEncode is set to false the text is not encoded and the br will work as expected. Unfortunately is not possible to specify this only for the header text, it will affect the cell contents as well.
这篇关于我如何打破BoundField的HeaderText的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!