?
Solved

gridview won't wrap text

Posted on 2010-09-09
5
Medium Priority
?
769 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

800 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