Solved

gridview won't wrap text

Posted on 2010-09-09
5
762 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

744 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now