Solved

gridview won't wrap text

Posted on 2010-09-09
5
765 Views
Last Modified: 2012-05-10
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>

Open in new window

0
Comment
Question by:iepaul
  • 2
  • 2
5 Comments
 
LVL 9

Expert Comment

by:puru1981
ID: 33635682
0
 
LVL 1

Expert Comment

by:ayan2010
ID: 33635838
Better to use template column, where you can put text-box or label which you can wrap. try it.
0
 

Author Comment

by:iepaul
ID: 33636261
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>
0
 

Author Comment

by:iepaul
ID: 33636275
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
0
 
LVL 9

Accepted Solution

by:
puru1981 earned 500 total points
ID: 33636665

try to set the width of the boundedcolumn, i think it will wrap.

Basically both of the above links talk about using CSS to do the wrapping of the text.

use overflow:hidden when you want to remove the overflow
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question