Solved

gridview won't wrap text

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

696 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