CheckBox in Datagrid

  • Thread starter Jim Ptak via .NET 247
  • Start date
J

Jim Ptak via .NET 247

I am desperate for help. I am at a loss. I have a dataset with 4columns in it. The first column is an actual column from adatabase table. The last three columns are hard codded values of0. I am using this dataset to populate a datagrid. The datagridhas a datagridtablestyle that has all four columns with the lastthree being DataGridBoolColumn's. This works great when I hit aSQL Server database. When I hit an Oracle database thecheckboxes are always grey and checked as if they are recievinga null value. I am beating my head against the wall. If anyonehas an answer please help. I have provided all pertinent codebelow.

In the OnLoad event of my control which has the datagrid on it Iput the DataGridTableStyle on the datagrid.

' Add a GridTableStyle
Dim tsSecurity As New DataGridTableStyle
tsSecurity.MappingName = "OBVIENT.OBV_WEB_PARTS"
tsSecurity.RowHeadersVisible = False

' Add a GridColumnStyle
Dim tcWebPart As New DataGridTextBoxColumn
tcWebPart.MappingName = "PRT_NAME"
tcWebPart.HeaderText = "Web Part"
tcWebPart.Alignment = HorizontalAlignment.Left
tcWebPart.ReadOnly = True
tcWebPart.Width = 175
tsSecurity.GridColumnStyles.Add(tcWebPart)

Dim tcAccess As New DataGridBoolColumn
tcAccess.MappingName = "ACCESSWP"
tcAccess.HeaderText = "Access"
tcAccess.Alignment = HorizontalAlignment.Center
tcAccess.AllowNull = False
tcAccess.ReadOnly = True
tcAccess.NullValue = False
tcAccess.TrueValue = True
tcAccess.FalseValue = False
tcAccess.Width = 75
tsSecurity.GridColumnStyles.Add(tcAccess)

Dim tcViewNotes As New DataGridBoolColumn
tcViewNotes.MappingName = "VIEWNOTES"
tcViewNotes.HeaderText = "View Notes"
tcViewNotes.Alignment = HorizontalAlignment.Center
tcViewNotes.AllowNull = False
tcViewNotes.ReadOnly = True
tcViewNotes.NullValue = 0
tcViewNotes.TrueValue = 1
tcViewNotes.FalseValue = 0
tcViewNotes.Width = 75
tsSecurity.GridColumnStyles.Add(tcViewNotes)

Dim tcEditNotes As New DataGridBoolColumn
tcEditNotes.MappingName = "EDITNOTES"
tcEditNotes.HeaderText = "Edit Notes"
tcEditNotes.Alignment = HorizontalAlignment.Center
tcEditNotes.AllowNull = False
tcEditNotes.ReadOnly = True
tcEditNotes.NullValue = 0
tcEditNotes.TrueValue = 1
tcEditNotes.FalseValue = 0
tcEditNotes.Width = 75
tsSecurity.GridColumnStyles.Add(tcEditNotes)




In the event where I bind my datagrid I have the following:

' Build the query with place holders for thepermissions.
strQuery = "SELECT PRT_NAME,0 ACCESSWP,0 VIEWNOTES,0EDITNOTES FROM OBVIENT.OBV_WEB_PARTS WHERE 1=1 "

adaptor = New OleDbDataAdapter(strQuery, oConn)
adaptor.Fill(dsAny, "OBVIENT.OBV_WEB_PARTS")

dgWebParts.DataSource =dsAny.Tables("OBVIENT.OBV_WEB_PARTS")
allowNewFalse(dgWebParts, BindingContext)


This works great against SQL Server and the check boxes performas expected. In Oracle the check boxes are always greyed out andchecked. Any help would be greatly appreciated.
 
D

Dmitriy Lapshin [C# / .NET MVP]

Hi Jim,

Try to disable nulls on the corresponding columns in the returned DataTable
before the grid gets bound.
You should also use the SetDataBinding method instead of assigning
DataSource directly.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://www.x-unity.net/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

I am desperate for help. I am at a loss. I have a dataset with 4 columns in
it. The first column is an actual column from a database table. The last
three columns are hard codded values of 0. I am using this dataset to
populate a datagrid. The datagrid has a datagridtablestyle that has all four
columns with the last three being DataGridBoolColumn's. This works great
when I hit a SQL Server database. When I hit an Oracle database the
checkboxes are always grey and checked as if they are recieving a null
value. I am beating my head against the wall. If anyone has an answer please
help. I have provided all pertinent code below.

In the OnLoad event of my control which has the datagrid on it I put the
DataGridTableStyle on the datagrid.

' Add a GridTableStyle
Dim tsSecurity As New DataGridTableStyle
tsSecurity.MappingName = "OBVIENT.OBV_WEB_PARTS"
tsSecurity.RowHeadersVisible = False

' Add a GridColumnStyle
Dim tcWebPart As New DataGridTextBoxColumn
tcWebPart.MappingName = "PRT_NAME"
tcWebPart.HeaderText = "Web Part"
tcWebPart.Alignment = HorizontalAlignment.Left
tcWebPart.ReadOnly = True
tcWebPart.Width = 175
tsSecurity.GridColumnStyles.Add(tcWebPart)

Dim tcAccess As New DataGridBoolColumn
tcAccess.MappingName = "ACCESSWP"
tcAccess.HeaderText = "Access"
tcAccess.Alignment = HorizontalAlignment.Center
tcAccess.AllowNull = False
tcAccess.ReadOnly = True
tcAccess.NullValue = False
tcAccess.TrueValue = True
tcAccess.FalseValue = False
tcAccess.Width = 75
tsSecurity.GridColumnStyles.Add(tcAccess)

Dim tcViewNotes As New DataGridBoolColumn
tcViewNotes.MappingName = "VIEWNOTES"
tcViewNotes.HeaderText = "View Notes"
tcViewNotes.Alignment = HorizontalAlignment.Center
tcViewNotes.AllowNull = False
tcViewNotes.ReadOnly = True
tcViewNotes.NullValue = 0
tcViewNotes.TrueValue = 1
tcViewNotes.FalseValue = 0
tcViewNotes.Width = 75
tsSecurity.GridColumnStyles.Add(tcViewNotes)

Dim tcEditNotes As New DataGridBoolColumn
tcEditNotes.MappingName = "EDITNOTES"
tcEditNotes.HeaderText = "Edit Notes"
tcEditNotes.Alignment = HorizontalAlignment.Center
tcEditNotes.AllowNull = False
tcEditNotes.ReadOnly = True
tcEditNotes.NullValue = 0
tcEditNotes.TrueValue = 1
tcEditNotes.FalseValue = 0
tcEditNotes.Width = 75
tsSecurity.GridColumnStyles.Add(tcEditNotes)




In the event where I bind my datagrid I have the following:

' Build the query with place holders for the permissions.
strQuery = "SELECT PRT_NAME,0 ACCESSWP,0 VIEWNOTES,0 EDITNOTES
FROM OBVIENT.OBV_WEB_PARTS WHERE 1=1 "

adaptor = New OleDbDataAdapter(strQuery, oConn)
adaptor.Fill(dsAny, "OBVIENT.OBV_WEB_PARTS")

dgWebParts.DataSource = dsAny.Tables("OBVIENT.OBV_WEB_PARTS")
allowNewFalse(dgWebParts, BindingContext)


This works great against SQL Server and the check boxes perform as expected.
In Oracle the check boxes are always greyed out and checked. Any help would
be greatly appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top