Click here to Skip to main content
15,904,416 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted

1 solution

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.NET
<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>
 
Share this answer
 
v2
Comments
Member 10380324 18-Dec-13 0:16am    
We can't change as we are using a customised grideview. In it we are using template column and all properties we use are different for our gridview. So please suggest another solution
What is customized GridView? Here only div is used instead of Label. You can also try adding the Label inside this div.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900