Add newline to Gridview cell

Discussion in 'ASP .Net Datagrid Control' started by John Doe, Apr 24, 2007.

  1. John Doe

    John Doe Guest

    I'm binding a Gridview to a DataTable. I want to display the Gridview cells
    with multiline values. In populating the data for the DataTable, I use
    Environment.Newline but the data doesn't display in Gridview as multiline:

    newRow[myDataColumn.Ordinal] = diff.ToString("N")+ Environment.Newline +
    pct.ToString("P");
     
    John Doe, Apr 24, 2007
    #1
    1. Advertising

  2. Look at your source code output and I would hazard a guess that your newline
    isn't being rendered as <br>, which in html would create a newline. If I
    recall correctly, you can only do this using templatefields, so have a read
    of a few tutorials like this one to start:

    http://aspnet101.com/aspnet101/tutorials.aspx?id=58

    Regards

    John Timney (MVP)
    http://www.johntimney.com
    http://www.johntimney.com/blog


    "John Doe" <> wrote in message
    news:...
    > I'm binding a Gridview to a DataTable. I want to display the Gridview
    > cells with multiline values. In populating the data for the DataTable, I
    > use Environment.Newline but the data doesn't display in Gridview as
    > multiline:
    >
    > newRow[myDataColumn.Ordinal] = diff.ToString("N")+ Environment.Newline +
    > pct.ToString("P");
    >
    >
    >
     
    John Timney \(MVP\), Apr 28, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ivan Demkovitch

    Newline detected when add script in C# (ASP.NET)

    Ivan Demkovitch, Nov 5, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    3,874
    Ivan Demkovitch
    Nov 5, 2003
  2. Timo
    Replies:
    1
    Views:
    913
    George Ter-Saakov
    Apr 23, 2004
  3. news.rcn.com
    Replies:
    1
    Views:
    9,689
    Chris Smith
    Jul 12, 2004
  4. Phillip Roncoroni
    Replies:
    14
    Views:
    1,104
    Toby A Inkster
    Apr 5, 2004
  5. Empire City
    Replies:
    3
    Views:
    414
    Empire City
    Apr 30, 2004
Loading...

Share This Page