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

restrict column to hold certain values


Hi,

I need a datacolumn in a databoundgrid that can check if the user entered in a number that is within a specified range. So, for example, if I specify a range that is between 10 and 20, the user cannot enter 100 into the column. Is there a maskedtextbox or something of that sort that I can use? Or is there another easy way to do it? Thanks!

1 Reply

GR Golda Rebecal Syncfusion Team September 26, 2007 03:57 AM UTC

Hi,

You can achieve this requirement by checking the required condition in CurrentCellValidating event.

Here is the code snippet:

void gridDataBoundGrid1_CurrentCellValidating(object sender, CancelEventArgs e)
{
GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
int value = Int32.Parse(cc.Renderer.ControlText);
if (value < 10 || value > 20 && cc.ColIndex == 1)
{
e.Cancel = true;
MessageBox.Show("Enter value between 10 and 20");
}
}

Kindly let me know if this helps you.

We appreciate your interest in Syncfusion products.

Best regards,
Golda

Loader.
Live Chat Icon For mobile
Up arrow icon