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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to prevent Null Col Values

Thread ID:

Created:

Updated:

Platform:

Replies:

19406 Sep 24,2004 08:23 PM UTC Sep 26,2004 10:57 PM UTC WinForms 3
loading
Tags: GridControl
Gaja
Asked On September 24, 2004 08:23 PM UTC

Hello How can i make a cell in a grid control mandatory Field.i.e allow no null in the col . The grid is linked to a datatable.. I can set the col property AllowDBNull to false.. Can''t i similarly set the porperty of the grid col

Administrator [Syncfusion]
Replied On September 24, 2004 09:41 PM UTC

If you set the DataColumn.AllowDbNull = false, then the grid should throw an exception each time your user tries to clear the cell. This should work witout ddition work if teh cell is a type like DataTime or double or anything other than a string. If this is a cell that has a string CellValue, then you may not want to allow the empty string as well. An empty string will not trigger the DBNull exception as an empty string is not null. To do this check take an extra step. You can handle the CurrentCellValidating event, and if grid.CurrentCell.Renderer.ControlText.Length == 0, then set e.Cancel = 0, and also set grid.CurrentCell.ErrorMessage if you want to see a message displayed.

Gaja
Replied On September 26, 2004 10:52 PM UTC

Thanks for the reply .. i did set the Property of the datatable to AllowDBNull to false .. but now how to do i override this(Message.bmp attached) default error message .. I get this message when i try to go to a new row before filling in the no null column values ...Thanks a lot again in advance >If you set the DataColumn.AllowDbNull = false, then the grid should throw an exception each time your user tries to clear the cell. This should work witout ddition work if teh cell is a type like DataTime or double or anything other than a string. > >If this is a cell that has a string CellValue, then you may not want to allow the empty string as well. An empty string will not trigger the DBNull exception as an empty string is not null. To do this check take an extra step. You can handle the CurrentCellValidating event, and if grid.CurrentCell.Renderer.ControlText.Length == 0, then set e.Cancel = 0, and also set grid.CurrentCell.ErrorMessage if you want to see a message displayed. Message_1268.zip

Administrator [Syncfusion]
Replied On September 26, 2004 10:57 PM UTC

You can handle the grid.ValidateFailed event. In the handler, you can set the message with code like: grid.CurrentCell.ErrorMessage = "My Message";

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.

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

;