("Problem"->i want to get checkboxes in the datagrid column. and the table(SQL) name is BrokSlab and the column name is "PercentageStatus".)
There is a datagrid Column "PercentageStatus" which contains a values '0 and 1'.Now i want to get this column in the datagrid instead of display 1 and 0 in the datagrid column i want to display checkboxes.Now the problem is i am getting this column with all checkboxes are checked and it look like hidden or i can say it looks like disable. so this is my coding. i am past all my coding. there 1 class which is called "DataBase" and the other is "SupportBrokSlab" all working is in this class "SupportBrokSlab".
GetData is used to get the filled table
now
in 1 we get all checkboxes are checked
and in 2 we get values 0 and 1
can anyone tell me whats is the problem in this?
Thanks
#
Region "Public"
Public objDb As New Database
#
End Region
#
Region "Private"
Private mTable As DataTable
#
End Region
Dim PercentageStatus_Col As New DataGridBoolColumn
Dim TableStyle As New DataGridTableStyle
Dim strquery As String = "Select * FROM BrokSlab "
Dim i As Integer
mTable = objDb.GetData(strquery)
DGrid.DataSource = mTable
---------------------1-----------------------------
mTable = objDB.GetData(strquery)
DGrid.DataSource = mTable
PercentageStatus_Col.MappingName = "PercentageStatus"
PercentageStatus_Col.HeaderText = "Percentage Status"
PercentageStatus_Col.Width = 100
PercentageStatus_Col.NullValue = True
TableStyle.GridColumnStyles.Add(PercentageStatus_Col)
DGrid.TableStyles.Add(TableStyle)
For i = 0 To mTable.Rows.Count - 1
If mTable.Rows(i).Item("PercentageStatus") = 1 Then
PercentageStatus_Col.TrueValue = True
End If
If mTable.Rows(i).Item("PercentageStatus") = 0 Then
PercentageStatus_Col.FalseValue = False
End If
Next
----------------------1------------------------------
Public Function GetData(ByVal query As String) As DataTable
Try
'msqlConnection = New SqlConnection(mConnStr)
mdataTable = New DataTable
msqlConnection.Open()
mSqlAdapter = New SqlDataAdapter(query, msqlConnection)
mSqlAdapter.Fill(mdataTable)
'mSqlAdapter.Fill(mDataSet)
msqlConnection.Close()
Return mdataTable
Catch ex As Exception
End Try
End Function
--------------------------------------------------------
in the above coding we get the column which is all checked but i want to get the
checkbox value from the data table but i cannot doing this. i dont know what is
the problem
---------------------2-----------------------------------
Dim i As Integer
Dim dc As New DataColumn
Dim ds As New DataSet
'Dim dr As DataRow
With dc
.ColumnName = "PercentageStatus"
.DataType = GetType(Boolean)
.DefaultValue = False
End With
ds = objDB.GetDataBroker(strquery, "BrokSlab", dc, DGrid,
"PercentageStatus")
DGrid.DataSource = ds.Tables("BrokSlab")
TableStyle.MappingName = "BrokSlab"
PercentageStatus_Col.MappingName = "PercentageStatus"
PercentageStatus_Col.HeaderText = "Percentage Status"
PercentageStatus_Col.Width = 100
PercentageStatus_Col.NullValue = False
TableStyle.GridColumnStyles.Add(PercentageStatus_Col)
DGrid.TableStyles.Add(TableStyle)
--------------------2---------------------------------------
Public Function GetDataBroker(ByVal query As String, ByVal tableName As
String, ByVal DataCol As DataColumn, ByVal dg As DataGrid, ByVal colName As
String) As DataSet
Try
Dim ds As New DataSet
Dim dc As New DataColumn
dc = DataCol
msqlConnection.Open()
mSqlAdapter = New SqlDataAdapter(query, msqlConnection)
mSqlAdapter.FillSchema(ds, SchemaType.Mapped, tableName)
If Not ds.Tables(tableName).Columns.Contains(colName) Then
ds.Tables(tableName).Columns.Add(dc)
mSqlAdapter.Fill(ds, tableName)
End If
msqlConnection.Close()
Return ds
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End Function
--------------------------------------------------------------
and in the above coding we get the value 1 and 0. but i want the checkbox. please tell me.