[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

ASP.net VB.net Load a GridView cell with lines one under the other

Posted on 2015-01-22
2
Medium Priority
?
331 Views
Last Modified: 2015-01-22
Hi

I gave the following text in a SQL database that I load to an ASP.net GridView. It loads as one long string so I am the code further on to load it into a Template field so that the lines are one under each other. It doesn't seem to work

 1.       In your organisation's daily operations, would you say honesty is practiced:|

(A)       Always|
(B)       Frequently|
(C)       Occasionaly|
(D)       Rarely|



Private Sub GridView3_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView3.RowDataBound
        Try
            ' Required to ignore the header and footer rows
            If e.Row.RowType = DataControlRowType.DataRow Then
                Dim oNumberAnswers As String = CStr(e.Row.Cells(5).Text)
                Dim oQuestion As String = CStr(e.Row.Cells(3).Text)
                Dim arrSplit As Object = Split(oQuestion, "|")
                Dim S As String = S
                For i As Integer = 0 To UBound(arrSplit)
                    If S = "" Then
                        S = arrSplit(i)
                    Else
                        S = S & vbCrLf & arrSplit(i)
                    End If
                Next
                e.Row.Cells(1).Text = S
0
Comment
Question by:Murray Brown
[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 Comments
 
LVL 13

Accepted Solution

by:
Jesus Rodriguez earned 2000 total points
ID: 40564695
You can do something like this

        Try
             If e.Row.RowType = DataControlRowType.DataRow Then
                    Dim MyNewText As String = String.Empty
        Dim MyFields As String() = Split(e.Row.Cells(3).Text, "|")
        For Each Field As String In MyFields
            MyNewText += Field & vbCrLf
        Next
       e.Row.Cells(1).Text=MyNewText
      Catch
     End try

Open in new window


If don't work with VbCrLf then try this
     MyNewText += Field & "<br/>"
0
 

Author Closing Comment

by:Murray Brown
ID: 40565860
Thanks
0

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

650 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