Link to home
Start Free TrialLog in
Avatar of ITHelper80
ITHelper80

asked on

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

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()
            Mycommand.Fill(MyDataSet)
            GridView1.DataSource = MyDataSet
            GridView1.DataBind()
 
 
 
            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.Columns.Add(DGTruck)
            GridView1.Columns.Add(DGOper)
            GridView1.Columns.Add(DGShift)
            GridView1.Columns.Add(DGDate)
            GridView1.Columns.Add(DGV1)
            GridView1.DataSource = MyDataSet
            GridView1.DataBind()

Open in new window

Avatar of kirihimete
kirihimete
Flag of United States of America image

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?
ASKER CERTIFIED SOLUTION
Avatar of ITHelper80
ITHelper80

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial