Gridview Column Validation

private void DGVResourceType_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{

#region Numeric Column in Gridview

if (e.ColumnIndex == DGVResourceType.Columns[“FINE_DAILY_AMOUNT”].Index) //this is our numeric column
{
int i;
if (!int.TryParse(Convert.ToString(e.FormattedValue), out i))
{
e.Cancel = true;
MessageBox.Show(“Must be numeric”, “Message”, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
if (e.ColumnIndex == DGVResourceType.Columns[“FINE_WEEKLY_AMOUNT”].Index) //this is our numeric column
{
int i;
if (!int.TryParse(Convert.ToString(e.FormattedValue), out i))
{
e.Cancel = true;
MessageBox.Show(“Must be numeric”, “Message”, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}

#endregion

}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: