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. Image for the cookie policy date
close icon

Null values for a DBG

Hey Clay, I have checked other posts such as http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=18016 on how to allow nulls, but so far I have been unsuccessful. I am using a databound grid version 1.6.1.8 where the column in question allows nulls and is of datatype Int32. All the rows in this column are initially null, and are later populated with integers. After they are populated I would like to allow the users to set previous values to null. I tried the suggestion in the referenced forum post. Example: private void btnExamsDeletePreClinic_Click(object sender, System.EventArgs e) { GridCurrentCell cc = this.gridExamPreClinic.CurrentCell; cc.EndEdit(); this.gridExamPreClinic[cc.RowIndex, cc.ColIndex].CellValue = DBNull.Value; } However I still get the message "is not a valid Int32". I have also tried hooking into the currentCellValidating event and setting the datasource to DBNull private void gridExamPreClinic_CurrentCellValidating(object sender, System.ComponentModel.CancelEventArgs e) { GridCurrentCell cc = this.gridExamPreClinic.CurrentCell; if (cc.ColIndex == 3) //this.gridTimeErrorQueue[cc.RowIndex, cc.ColIndex].CellValueType.Equals(typeof(DateTime))) { try { string proposedValue = cc.Renderer.ControlText; this.preclinicDataset.Tables[0].Rows[cc.RowIndex - 1][2] = System.DBNull.Value; } catch { cc.ErrorMessage = "asdfasdf"; e.Cancel = true; } } } However I still get the invalid Int32 message. Any suggestions?! JF

3 Replies

AD Administrator Syncfusion Team September 7, 2004 04:47 PM UTC

Using 1618 in the sample below, I am able to delete integers in the last column using the keyboard without seeing the message. I can also delete them using the button handler in teh sample. What are you doing differently? WindowsApplication21_4412.zip


JF Jim Frapper September 7, 2004 05:08 PM UTC

I have discovered the difference. I am using a cell type of masked edit. Put the following code this.gridDataBoundGrid1.Model.ColStyles[5].CellType = "MaskEdit"; this.gridDataBoundGrid1.Model.ColStyles[5].MaskEdit.Mask = "999"; this.gridDataBoundGrid1.Model.ColStyles[5].MaskEdit.MaxValue = 100; after this line in your sample this.gridDataBoundGrid2.DataSource = dt; I am using the masked edit cell type to make sure the users put in a value up to 100. Here is the raw requirements: - Allow users to enter integer values from 0 to 100 - Allow users to null out data they have already entered. JF


AD Administrator Syncfusion Team September 7, 2004 05:27 PM UTC

I suspect the mask edit would work OK in 2.1.0.9 handling the null value. In 1618, you can do this using a TextBox celltype and avoid the use of the mask edit (and the null problem.) Handle the CurrentCellValidateString method. In it, check if e.Text is a valid integer in the range you want. If not, then set e.Cancel = true.

Loader.
Live Chat Icon For mobile
Up arrow icon