Which code segment should you use?

You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET.

The application has an untyped DataTable object named tblCustomer.
The tblCustomer object contains a DataColumn named Age.

You plan to create a ColumnChanging event handler for the tblCustomer object. You need to ensure that when the existing data is modified, any value in the Age DataColumn that is greater than 100 is set to DBNull.

Which code segment should you use?

You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET.

The application has an untyped DataTable object named tblCustomer.
The tblCustomer object contains a DataColumn named Age.

You plan to create a ColumnChanging event handler for the tblCustomer object. You need to ensure that when the existing data is modified, any value in the Age DataColumn that is greater than 100 is set to DBNull.

Which code segment should you use?

A.
void ValidateChanges(object sender, DataColumnChangeEventArgs e)
{
if (e.Column.ColumnName == "Age" && ProposedValue!=DBNull.Value)
{
if ((int)e.Row["Age"] > 100)
{
Row["Age"] = DBNull.Value;
}
}
}

B.
void ValidateChanges(object sender, DataColumnChangeEventArgs e)
{
if (e.Column.ColumnName == "Age" && ProposedValue!=DBNull.Value)
{
if ((int)e.ProposedValue > 100)
{
Row["Age"] = DBNull.Value;
}
}
}

C.
void ValidateChanges(object sender, DataColumnChangeEventArgs e)
{
if (e.Column.ColumnName == "Age" && ProposedValue!=DBNull.Value)
{
if ((int)e.Row["Age"] > 100)
{
ProposedValue = DBNull.Value;
}
}
}

D.
void ValidateChanges(object sender, DataColumnChangeEventArgs e)
{
if (e.Column.ColumnName == "Age" && ProposedValue!=DBNull.Value)
{
if ((int)e.ProposedValue > 100)
{
ProposedValue = DBNull.Value;
}
}
}



Leave a Reply 0

Your email address will not be published. Required fields are marked *