line feeds in Gridview cells? vbcrlf ? new line?

Discussion in 'ASP .Net' started by wildman@noclient.net, Mar 6, 2008.

  1. Guest

    Is there any way for gridview cells to observe vbcrlf in the data?

    I attempted to do this, but it does not seem to work.

    Dim dgItem As GridViewRow
    For Each dgItem In gridCollaborator.Rows
    dgItem.Cells(6).Text.Replace("-", vbCrLf + "-")
    Next

    I also tried <br>, no luck

    Thanks for any help or infomation.
     
    , Mar 6, 2008
    #1
    1. Advertising

  2. Elmo Watson Guest

    You'll need to start with:

    If e.Row.RowType = DataControlRowType.DataRow Then (of course add your
    code, and then End If)

    then try:
    dgItem.Cells(6).Text=dgItem.Cells(6).Text.Replace("-", vbCrLf + "-")


    David Wier
    http://aspnet101.com
    http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with no
    bloated markup


    <> wrote in message
    news:...
    > Is there any way for gridview cells to observe vbcrlf in the data?
    >
    > I attempted to do this, but it does not seem to work.
    >
    > Dim dgItem As GridViewRow
    > For Each dgItem In gridCollaborator.Rows
    > dgItem.Cells(6).Text.Replace("-", vbCrLf + "-")
    > Next
    >
    > I also tried <br>, no luck
    >
    > Thanks for any help or infomation.
     
    Elmo Watson, Mar 6, 2008
    #2
    1. Advertising

  3. On Mar 6, 8:53 pm, wrote:
    > Is there any way for gridview cells to observe vbcrlf in the data?
    >
    > I attempted to do this, but it does not seem to work.
    >
    >         Dim dgItem As GridViewRow
    >         For Each dgItem In gridCollaborator.Rows
    >             dgItem.Cells(6).Text.Replace("-", vbCrLf + "-")
    >         Next
    >
    > I also tried <br>, no luck
    >
    > Thanks for any help or infomation.


    dgItem.Cells(6).Text.Replace("-", vbCrLf + "-") would replace "-" by
    the vbCrLf + "-" what makes no sense for the browser if you don't use
    <pre> tag that preserves line breaks. Changing to "<br/>-" should make
    a break in the text
     
    Alexey Smirnov, Mar 6, 2008
    #3
  4. dgItem.Cells(6).Text.Replace("-", "<br/>-")

    should work, unless the content is actually in a child control in the cell
    such as a label.

    -- Peter
    Site: http://www.eggheadcafe.com
    UnBlog: http://petesbloggerama.blogspot.com
    Short Urls & more: http://ittyurl.net


    "" wrote:

    > Is there any way for gridview cells to observe vbcrlf in the data?
    >
    > I attempted to do this, but it does not seem to work.
    >
    > Dim dgItem As GridViewRow
    > For Each dgItem In gridCollaborator.Rows
    > dgItem.Cells(6).Text.Replace("-", vbCrLf + "-")
    > Next
    >
    > I also tried <br>, no luck
    >
    > Thanks for any help or infomation.
    >
     
    Peter Bromberg [C# MVP], Mar 6, 2008
    #4
    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. Patrick Olurotimi Ige
    Replies:
    2
    Views:
    508
    Patrick Olurotimi Ige
    May 5, 2005
  2. Replies:
    0
    Views:
    538
  3. MSNews

    Line feeds in a GridView

    MSNews, Nov 4, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    363
    MSNews
    Nov 4, 2006
  4. Joel Finkel

    Cells[].Text or Cells[].Controls[0]

    Joel Finkel, Sep 1, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    319
    Joel Finkel
    Sep 1, 2003
  5. Jason
    Replies:
    6
    Views:
    173
    Aaron Bertrand - MVP
    Oct 20, 2003
Loading...

Share This Page