Solved

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

Posted on 2015-01-22
2
324 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 500 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

717 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