We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Default Check Box Value

Thread ID:





43707 May 1,2006 03:48 PM UTC May 3,2006 09:23 AM UTC WinForms 3
Tags: GridControl
Chad Elliot
Asked On May 1, 2006 03:48 PM UTC

I have a GridDataBoundGrid that has a check box column. The column it is bound to only accepts 1 and 0. If I do not click the check box and try to save the row, I get an error saying that the column does not allow null values. Is there a way to set a default value for the check box column so that when new records are added, it will have a value of 0?

Administrator [Syncfusion]
Replied On May 2, 2006 07:26 AM UTC

Hi Chad, Please try setting the CheckBoxOptions property for the checkboxcolumn in the grid, see if this helps. grid.Binder.InternalColumns["CheckBoxColumn"].StyleInfo.CellType = "CheckBox"; grid.Binder.InternalColumns["CheckBoxColumn"].StyleInfo.CheckBoxOptions = new GridCheckBoxCellInfo("1", "0", DBNull.Value.ToString(), true); Please refer to the forum thread below, http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=18606 Refer to KnowledgeBase(KB) article below, for the details on CheckBoxOptions property. http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=28 Let us know if you need any further assistance. Regards, Rajagopal

Chad Elliot
Replied On May 2, 2006 12:45 PM UTC

I tried that and it does not work in my case. I have a data grid that is loaded with the contents of a single table. One column is a bit column, which does not allow NULL values and has a default of 0. The code that updates the data uses the SqlComandBuilder object to build the insert, update, and delete statements based on the select statement (SELECT * FROM [Table]). When the user enters a new row in the data grid, the value for the check box column in the dataset is NULL, but when the record is inserted into the SQL table, the column is populated with the default value of 0. If the user tries to change the record they just added, the update fails because the value of the check box column in the data set is not the same as the value in the SQL table. I need a way to default the check box column to 0 in the data set so subsequent updates to the record will work.

Administrator [Syncfusion]
Replied On May 3, 2006 09:23 AM UTC

Hi Chad, Please set the AllowDBNull property to false for the checkbox column in the table and also set the DefaultValue for it to 0. this.dataSet11.Tables[0].Columns["CheckboxCol"].AllowDBNull = false; this.dataSet11.Tables[0].Columns["CheckboxCol"].DefaultValue = 0; this.grid.DataSource = this.dataSet11.Tables[0]; Let us know if this helps. Thanks, Rajagopal


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon