ITHelper80
asked on
Convert True/False value from Gridview into Number with
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 3...how can I get the actual value to show up?
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()
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.
ASKER
Sorry, I should have specified the fied...no its DGShift.
But I suspect the conversion to int is what I am looking for...can you give me a snippet?
But I suspect the conversion to int is what I am looking for...can you give me a snippet?
It will depend somewhat on how you define your dataset but here's one way to create a column:
ds.Tables(0).Columns.Add(N ew DataColumn("DGShift", Type.GetType("System.Int32 ")))
ds.Tables(0).Columns.Add(N
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.