Solved

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

Posted on 2015-01-22
2
312 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:murbro
2 Comments
 
LVL 13

Accepted Solution

by:
Jesus Rodriguez earned 500 total points
Comment Utility
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:murbro
Comment Utility
Thanks
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

763 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now