Click here to Skip to main content
15,903,203 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to break the row in to multiple sub row.
For example : I have a row like this

Hello world how r u.


i need the output as below

Hello world
how r u..
Posted

If you want to wrap the sentence then you can add a <br> wherever you want to break the same
In your case it will be like

Hello world <br>
how r u..

-Amol
 
Share this answer
 
v2
Comments
Asif Iqbal A.Khan 22-Jun-11 5:12am    
I have used <br/>, \r\n, and Environment.newLine. These all are not working
use <br /> Tag in your content
Row1<br />Row2<br />Row3

It'll show you output like below
Row1
Row2
Row3

BTW you can wrap the content by using ItemStyle-Wrap="true"
<asp:gridview id="GridView1" runat="server" xmlns:asp="#unknown">
<columns>
<asp:boundfield itemstyle-wrap="true" datafield="Column1" />
</columns>
</asp:gridview>
 
Share this answer
 
Comments
Asif Iqbal A.Khan 22-Jun-11 5:13am    
I want to maintain it by Code behind. not in source.. Can u help me.
thatraja 22-Jun-11 5:35am    
If you give the same content Row1<br />Row2<br />Row3 in your data to grid then surely it will display the same. Try.
Option 1: Set "appropriate" width for that column and set the wrap property to true. Both the properties can be found in ItemStyle of the GridView.

Option 2: In the RowDataBound event, check for that column, and change the text to add \n after the number of words you want. Do remember to set the wrap property of the column to true.

Hope this helps!
 
Share this answer
 
I got a solution for my problem... following is the code for that. In the following code the important thing is we have to set the property of the column as HtmlEncode="False"

XML
<asp:GridView ID="GridView1"  Width="900px" runat="server" BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid" BorderWidth="3px" CellPadding="4" CellSpacing="2" ForeColor="Black"  AutoGenerateColumns="False">
                                <FooterStyle BackColor="#CCCCCC" />
                                <RowStyle BackColor="White" />
                                <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
                                <PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" />
                                <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
                                <Columns>
                                    <asp:BoundField DataField="Machineid" HeaderText="Machineid" HtmlEncode="False" ItemStyle-Width="250px" />
                                    <asp:BoundField DataField="Status" HeaderText="Status" HtmlEncode="False" ItemStyle-Width="650px"/>
                                </Columns>
                            </asp:GridView>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900