Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 530
  • Last Modified:

DataGridTextBoolColumn Showing Greyed Out

datagridtextboolcolumn showing greyed out. vb .net 2003

It is a bound column from an sql database with a boolean value. I have set allownulls to false, truevalue to true and false value to false and it just displays greyed out
0
Steve_Laurence
Asked:
Steve_Laurence
  • 4
  • 4
1 Solution
 
lorelogicCommented:
Are you bound to a view in the database or a query that joins tables? If so, you will not be able to modify them from the control directly and it will show greyed out. The values should still display though, even though greyed out. Are the values displayed?
0
 
Steve_LaurenceAuthor Commented:
It is a view of a single table and I can update other fields in the datagrid and successfully update them back to the sql database. When I debug though and trap on the currentcellchangedevent the value is showing as null. If a click a couple of times then the checkbox will go blank and then checked but when I exit the cell it reverts to grey however the new value is written back to the database. I am using a view because I want the user to be able to update existing rows but not to add or delete rows
0
 
lorelogicCommented:
Since the checkboxes are displaying grey (indicating a null value), but they do accept changes (checked or unchecked) that are posted back to the database, it seems that the datagrid is not being bound until after the initial display. Check to make sure that your pageload event has the datagrid being bound and on the postback events. Checkboxes do not retain state on postbacks (including autopostbacks), but textboxes do retain the state. This requires the datagrid to be rebound on each postback.
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
Steve_LaurenceAuthor Commented:
Okay I should have mentioned that this is a win forms project not web forms and usually all you have to do it give it the datasource. There is a databindings option but I am not familiar with how that works. Thanks for your help on this by the way
0
 
lorelogicCommented:
Is 'boolean' field you are binding to a MS SQL Server DB 'bit' data type? Are you using a dataAdapter to fill the dataset that the datagrid is bound to?
0
 
Steve_LaurenceAuthor Commented:
Yes it is a bit data type and the data is retrieved and updated using a webservice which invokes a dataadapter and returns the dataset I then create a dataview which the datagrid is bound to
0
 
lorelogicCommented:
Here is a link to an article that might explain the problem you are having:

http://www.dotnetfun.com/articles/winforms/DataGridBoolColumnValueProblem.aspx
0
 
Steve_LaurenceAuthor Commented:
That's it it worked. I guess this is like the old saying 'beware the Greeks bearing gifts', Microsoft and their wizards!!

Thanks very much for your persisitance on this
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now