Convert True/False value from Gridview into Number with

Posted on 2009-04-28
Last Modified: 2012-05-06
I am pulling in a field (tinyint) from a MySQL server and once its bound to the gridview it shows True or False....the database values only consist of 1,2 or can I get the actual value to show up?
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 18

    Expert Comment

    Is it the field that goes in DGV1?  That's a checkbox.  You can define the column in your dataset as an int and it shouldn't convert it to boolean.
    LVL 6

    Author Comment

    Sorry, I should have specified the its DGShift.

    But I suspect the conversion to int is what I am looking for...can you give me a snippet?
    LVL 18

    Expert Comment

    It will depend somewhat on how you define your dataset but here's one way to create a column:
    ds.Tables(0).Columns.Add(New DataColumn("DGShift", Type.GetType("System.Int32")))
    LVL 6

    Accepted Solution

    .Thanks but I ended up having to change the table type to VarChar to get it to work

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    Join & Write a Comment

    For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK ( for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
    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 …
    This video discusses moving either the default database or any database to a new volume.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    729 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

    21 Experts available now in Live!

    Get 1:1 Help Now