// Replace the NorthwindDataSet partial class with the following:
public partial class NorthwindDataSet
{
partial class OrdersDataTable
{
public override void EndInit()
{
base.EndInit();
// Configure the ColumnChanging event
// to call the SampleColumnChangingEvent method.
ColumnChanging += SampleColumnChangingEvent;
}
public void SampleColumnChangingEvent(object sender, System.Data.DataColumnChangeEventArgs e)
{
if (e.Column.ColumnName == OrderDateColumn.ColumnName)
{
if ((System.DateTime)e.ProposedValue > System.DateTime.Today)
{
e.Row.SetColumnError("OrderDate", " OrderDate cannot be in the future");
}
else
{
e.Row.SetColumnError("OrderDate", "");
}
}
}
}
}