473,386 Members | 1,741 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,386 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 6377
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.