?
Solved

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

Posted on 2015-01-22
2
Medium Priority
?
327 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

801 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