How to keep whitespace in datagrid

48175 pts.
Tags:
.NET
AS/400
IBM iSeries
SQL
SQL statements
I have a simple .NET app. You key a SQL statement into a text box. It then connects to any one of 5 i-Series and returns a datagrid. I am curious as to how I can preserve the whitespace in the columns. These columns have some fields with data right and left justified. Other fields a large field that have data substringed out (998 char)
My grid is defined
<div><asp:GridView ID="dgResults" AutoGenerateColumns="true" OnRowDataBound="dgResults_RowDataBound" Font-Names="courier" CellPadding="2" runat="server"></asp:GridView>
</div>
The VB code to populate the grid
Dim myConnection As New iDB2Connection(strConnection)
        Dim myCommand As New iDB2Command(mySQL, myConnection)

        myCommand.CommandTimeout = 0

        myCommand.Connection.Open()

        Dim myReader As iDB2DataReader

        Try
            myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)

            If myReader.HasRows = False Then
                lblError.Text = "No rows returned for SQL statement"
                lblError.Visible = True

                myReader.Close()
                myConnection.Close()
                dgResults.DataSource = Nothing
                dgResults.DataBind()

            Else

                Dim fields As Integer = myReader.FieldCount

                dgResults.DataSource = myReader
                dgResults.DataBind()

                myReader.Close()
                myConnection.Close()

                lblError.Text = " "
                lblError.Visible = False

            End If

        Catch ex As Exception
            lblError.Text = ex.Message
            lblError.Visible = True


Software/Hardware used:
sql, .net, i-Series, as/400

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: