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.
Unfortunately, activation email could not send to your email. Please try again.

Null values for a DBG

Thread ID:

Created:

Updated:

Platform:

Replies:

18698 Sep 7,2004 12:14 PM Sep 7,2004 01:27 PM Windows Forms 3
loading
Tags: GridControl
Jim Frapper
Asked On September 7, 2004 12:14 PM

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

Administrator [Syncfusion]
Replied On September 7, 2004 12:47 PM

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

Jim Frapper
Replied On September 7, 2004 01:08 PM

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

Administrator [Syncfusion]
Replied On September 7, 2004 01:27 PM

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.

CONFIRMATION

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.

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.

;