Convert Boolean value to string in ASP.NET and MySQL server

Posted on 2009-04-28
Last Modified: 2012-05-06
I have several fields that are boolean (0,1) and  am binding them to my ASPX page with a gridview control. By default the table is showing check boxes, is it possible to convert the values to Y or N?
Dim MyDataSet As New DataSet()


            GridView1.DataSource = MyDataSet


            Dim DGTruck As BoundField = New BoundField()

            Dim DGOper As BoundField = New BoundField()

            Dim DGShift As BoundField = New BoundField()

            Dim DGDate As BoundField = New BoundField()

            Dim DGV1 As BoundField = New CheckBoxField()

            DGTruck.DataField = "Truck"

            DGTruck.HeaderText = "Truck"

            DGTruck.SortExpression = "Truck"

            DGOper.DataField = "Operator"

            DGOper.HeaderText = "Operator"

            DGOper.SortExpression = "Operator"

            DGShift.DataField = "Shift"

            DGShift.HtmlEncode = False

            'DGShift.DataFormatString = "{0:n)"

            DGShift.HeaderText = "Shift"

            DGShift.SortExpression = "Shift"

            DGDate.DataField = "Date"

            DGDate.DataFormatString = "{0:MM/dd/yyyy}"

            DGDate.HtmlEncode = False

            DGDate.HeaderText = "Date"

            DGDate.SortExpression = "Date"

            DGV1.DataField = "V1"

            DGV1.HeaderText = "Condition"

            DGV1.SortExpression = "V1"






            GridView1.DataSource = MyDataSet


Open in new window

Question by:ITHelper80
    LVL 2

    Expert Comment

    inside the gridview you will need a template field.  Inside the template field you can have a label and bind the labels text property to a database field. Then on RowDataBound() or GridViewDataBound() you can check the value coming in from the data and based on that logic display Y or N.  Does this make sense?
    LVL 6

    Accepted Solution

    Thanks but I found another way. I set the fields as New Boundfield() and then used the below code.
            Dim i As Integer = 4
            Do Until i = 25
                If e.Row.RowType = DataControlRowType.DataRow Then
                    If e.Row.Cells(i).Text = True Then
                        e.Row.Cells(i).Text = "Y"
                        i = i + 1
                    ElseIf e.Row.Cells(i).Text = False Then
                        e.Row.Cells(i).Text = "N"
                        i = i + 1
                    End If
                    Exit Do
                End If

    Open in new window


    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
    Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    746 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

    16 Experts available now in Live!

    Get 1:1 Help Now