iepaul
asked on
gridview won't wrap text
I have a gridview where the status field can need to be wrapped because it is longer than the space available. I cannot get this work, I have attached my code for gridview.
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AutoGenerateColumns="False" CellPadding="2" DataKeyNames="fldID"
DataSourceID="SqlDataSource1" ForeColor="#333333" GridLines="None" CellSpacing="4" >
<RowStyle BackColor="#EFF3FB" />
<Columns>
<asp:boundfield DataField="fldID" HeaderText="ID" ReadOnly="True" InsertVisible="False" SortExpression="fldID">
<ItemStyle HorizontalAlign="Center" />
</asp:boundfield>
<asp:boundfield DataField="fldDateRaised" DataFormatString="{0:dd/MM/yyyy}" HeaderText="Raised" HtmlEncode="False" SortExpression="fldDateRaised">
<ItemStyle HorizontalAlign="Center" />
</asp:boundfield>
<asp:boundfield DataField="fldAssignedTo" HeaderText="Assigned" SortExpression="fldAssignedTo">
<ItemStyle HorizontalAlign="Center" />
</asp:boundfield>
<asp:boundfield DataField="fldDateClosed" DataFormatString="{0:dd/MM/yyyy}" HeaderText="Closed" HtmlEncode="False" SortExpression="fldDateClosed">
<ItemStyle HorizontalAlign="Center" />
</asp:boundfield>
<asp:boundfield DataField="fldStatus" HeaderText="Status" SortExpression="fldStatus" ItemStyle-Wrap="true" HtmlEncode="false">
<ItemStyle Wrap="True" />
</asp:boundfield>
</Columns>
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle HorizontalAlign="Center" BackColor="#2461BF" ForeColor="White" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<EditRowStyle VerticalAlign="Top" BackColor="#2461BF" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
Better to use template column, where you can put text-box or label which you can wrap. try it.
ASKER
changing to a template field makes no difference
<asp:templatefield HeaderText="Status" SortExpression="fldStatus" ItemStyle-Wrap="true">
<EditItemTemplate>
<asp:TextBox runat="server" Text='<%# Bind("fldStatus") %>' id="TextBox1">
</asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label runat="server" Text='<%# Bind("fldStatus") %>' id="Label1">
</asp:Label>
</ItemTemplate>
<ItemStyle Wrap="True" />
</asp:templatefield>
<asp:templatefield HeaderText="Status" SortExpression="fldStatus"
<EditItemTemplate>
<asp:TextBox runat="server" Text='<%# Bind("fldStatus") %>' id="TextBox1">
</asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label runat="server" Text='<%# Bind("fldStatus") %>' id="Label1">
</asp:Label>
</ItemTemplate>
<ItemStyle Wrap="True" />
</asp:templatefield>
ASKER
one of the suggested links is to do with tables and i am not sure what to do with the sample code provided in the other
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://www.eggheadcafe.com/community/aspnet/17/10083233/wrap-text-in-gridview.aspx
http://bytes.com/topic/html-css/answers/627827-how-wrap-text-css