如何在gridivew的模板字段的项模板中打破一个长字? [英] How to break a long word in the item template of template field of gridivew?
问题描述
如何在gridivew的模板字段的项目模板中打破长字?
< asp:TemplateColumn HeaderText =New EMPID>
< itemtemplate>
< asp:Label ID =Deletedrunat =serverStyle =word-wrap:break-word; Text ='<%#DataBinder.Eval(Container,DataItem.EmpId_Temp)%>'>< / asp:Label>
< / itemtemplate>
< headerstyle width =7%/>
< / asp:TemplateColumn>
这里的上述样式与IE 8浏览器的兼容性视图一起使用。但没有兼容性查看它走出gridview。
参考 - Gridview文本未包装在IE8中 [ ^ ]
引用:我看过你的问题。它似乎是IE8的一个问题,或者自动换行不符合新的HTML标准。
网格视图呈现为表格和您传递的数据在gridview中,直接进入 TD 。即使我们在 TD 中输入单词-wrap,也就是8,它不起作用。
一种方法可以解决你的问题使用TemplateField。您可以在DIV等容器中添加数据,并提供自动换行:break-word 和 width 属性。喜欢 -
< asp:TemplateField HeaderText = 显示问题汇总? HeaderStyle-Width = 40% ItemStyle-HorizontalAlign = 中心
ItemStyle-Width = 40% >
< ItemTemplate >
< div style = word-wrap:break-word;宽度:300px; border:solid 1px red; >
<% #Eval ( DisplayOnIssueSummary)%> < / div >
< / ItemTemplate >
< / asp:TemplateField >
How to break a long word in the item template of template field of gridivew?
<asp:TemplateColumn HeaderText="New EmpId"> <itemtemplate> <asp:Label ID="Deleted" runat="server" Style="word-wrap: break-word;" Text='<%# DataBinder.Eval(Container, "DataItem.EmpId_Temp") %>'></asp:Label> </itemtemplate> <headerstyle width="7%" /> </asp:TemplateColumn>
Here the above style does work with compatibility view of IE 8 browser. But without compatibility view its going out of the gridview.
Refer- Gridview text not wrapping in IE8[^]
Quote:I have looked at your problem. Its seems this is an issue of IE8 or the word-wrap is not valid as per new HTML standard.
A grid view is rendered as table and the data you pass in the gridview, directly goes inside a TD s. And in ie 8 even if we put word -wrap in TD , it does not work.
One way you can solve your problem by using TemplateField. You can add your data inside a container like DIV and give the word-wrap:break-word and the width property. Like-
<asp:TemplateField HeaderText="Display On Issue Summ?" HeaderStyle-Width="40%" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="40%"> <ItemTemplate> <div style="word-wrap: break-word; width: 300px; border: solid 1px red;"> <%#Eval("DisplayOnIssueSummary") %></div> </ItemTemplate> </asp:TemplateField>
这篇关于如何在gridivew的模板字段的项模板中打破一个长字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!