Solved

gridview won't wrap text

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

911 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

18 Experts available now in Live!

Get 1:1 Help Now