473,395 Members | 2,796 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

CheckBox in Datagrid

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.

--------------------------------
From: Jim Ptak

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>0VUhmrfj1EilLOiKMHFn9A==</Id>
Nov 16 '05 #1
1 6378
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

"Jim Ptak via .NET 247" <an*******@dotnet247.com> wrote in message
news:uW**************@TK2MSFTNGP11.phx.gbl...
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.

--------------------------------
From: Jim Ptak

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>0VUhmrfj1EilLOiKMHFn9A==</Id>

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Just D | last post by:
Hi All, Does anybody know how to write the following code? I have a database table with a few columns including: ID , "Task" , ForceRun . I need to show the DataGrid on the ASPX page with...
2
by: Sebi | last post by:
Hello all is it possible to add a checkbox in a DataGrid for Boolean Data? Thanks in advance
0
by: mike | last post by:
Hi there: I've read an excellent "how to"-article by Microsoft (no. 306227) - partly cited cited at the end of this email). I have implemented the code related to the part "How to Add a...
1
by: iforsyth | last post by:
Have a paging datagrid with a checkbox control in column(0). ViewState is enabled. I check the checkbox in first row of the grid on a page and then the program hits this event: Private Sub...
0
by: mehul | last post by:
CheckBox template always evaluate to False even if checked in a DataGrid hosted inside a TabStrip in ASP.NET Hi, I am trying to develop an ASP.NET application. I am using TabStrip (which is...
7
by: Lars Netzel | last post by:
If I put a checkbox in a datagrid (ASP.NET) and set the Autopostback to true I can catch OnChange event on checkbox but how do I then catch what DataGridItemIndex is? Can I use some Event in the...
10
by: Jennyfer J Barco | last post by:
Hello, I have a datagrid that brings some information from a query. I need to have a checkbox in each row so the user can select the rows he wants to reprint. Is it possible to have a checkbox...
2
by: Adam Knight | last post by:
Hi all, I have a datagrid with a checkbox in one column. The checkbox is set to autopostback and calls a method named UpdateMailSubscribers. The first click on the checkbox cause the page to...
9
by: Rekha | last post by:
The data is filled in datagrid. I want to know how to add a checkbox column in datagrid? In the runtime, checkbox is checked then instead of checkbox value the (caseID )column value is retained....
3
by: Fao, Sean | last post by:
I have a DataGrid that I'm adding CheckBox controls to at runtime (in the code behind) and I'm not sure if I'm doing it correctly. First of all, I noticed that the MyDataGrid.Columns.Add() method...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.