The output is like this:
MyNameIsJohnSmithAnd
Imaperson
What I want is to display it in only one line
MyNameIsJohnSmithAndImaperson
My Aspx gridview code is:
<asp:GridView ID="GridView1" runat="server" BackColor="LightGoldenrodYellow"
BorderColor="Tan" BorderWidth="1px" CellPadding="5" Font-Names="Calibri"
Font-Size="Medium" Font-Underline="False" ForeColor="Black">
<RowStyle Wrap="False"/>
<EmptyDataRowStyle Wrap="False"/>
<FooterStyle BackColor="Tan" BorderColor="Black" BorderStyle="Solid" Wrap="False"/>
<PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue"
HorizontalAlign="Center" Wrap="False" />
<SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" Wrap="False"/>
<HeaderStyle BackColor="Tan" BorderStyle="Solid" Font-Bold="True" Wrap="False"/>
<EditRowStyle Wrap="False"/>
<AlternatingRowStyle BackColor="PaleGoldenrod" Wrap="False"/>
</asp:GridView>
I disabled all the wrap property to false in gridview. but the text still wraps.
You have to set the gridview's individual column's word wrap to False as well.
<asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" >
<ItemStyle Wrap="False" />
</asp:BoundField>
Try adding this event to your gridview.
protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
for (int i = 0; i < e.Row.Cells.Count; i++)
{
e.Row.Cells[i].Attributes.Add("style", "white-space: nowrap;");
}
}
Here is the reference.
Very simple in .Net Select your grid view (as in Design mode) in property window and follow this RowStyle -->Font -->>Wrap=False
Thats done
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With