Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6914751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:23:18+00:00 2026-05-27T09:23:18+00:00

In my partial class containing the DataSet event I have the following: protected override

  • 0

In my partial class containing the DataSet event I have the following:

protected override void OnColumnChanging(System.Data.DataColumnChangeEventArgs e)
{
    switch (e.Column.ColumnName)
    {
        case "ColumnA":
        {
            int value = GetValue(e.ProposedValue.ToString());

            if (value == -1)
            {
                e.Row.SetColumnError("ColumnA", string.Format("ColumnA could not map [{0}] to a valid value", e.ProposedValue));
                //e.ProposedValue = "";
           }

           break;
       }

       base.OnColumnChanging(e);
}

When I check for errors and get the column errors for my rows I see the appropriate message when GetValue(…) returns -1. I also see that the column in that has the bad data still contains that bad value. I was under the impression that calling SetColumnError(…) would reject the change made to that column (ColumnA) as per: How to: Validate Data During Column Changes

Reject the proposed value by setting the column error (SetColumnError)
from within the column-changing event handler.

So when I try to do something like the following:

TypedDataSet set = new TypedDataSet();
TypedDataTable.TypedDataRow row = set.TypedDataTable.NewRow();
row.ColumnA = "Bad Data";
set.TypedDataTable.AddTypedDataRow(row);

I’ll see the validation code execute, but the value of ColumnA retains: “Bad Data”. If I go as far as setting e.ProposedValue = null I can see the value change.

Update

Add event handlers for either RowsChanging or ColumnsChanging also produce similar results.

public override void BeginInit()
{
    base.BeginInit();
    TypedRowChanging += new TypedRowChangeEventHandler(TypedDataTable_TypedRowChanging);
    ColumnChanging += new DataColumnChangeEventHandler(TypedDataTable_ColumnChanging);
}

Code in both of the event handlers is trivial and will call e.Row.SetColumnError(“ColumnA”, “some error”). So my original question remains:

What should be happening the in case where a column error is set on a column? Should it retain value, become null, 42?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T09:23:18+00:00Added an answer on May 27, 2026 at 9:23 am

    After much testing and work I’ve come to the conclusion that the column retains the value when a column error is set on a specific column. My current solution is to check for errors on the entire DataSet and then proceed to aggregate those errors into a format for error handling

    TypedDataSet set = new TypedDataSet();
    TypedDataTable.TypedDataRow row = set.TypedDataTable.NewRow();
    row.ColumnA = "Bad Data";
    set.TypedDataTable.AddTypedDataRow(row);
    
    // At this point the DataSet has column errors and can be checked for...
    if (set.HasErrors)
    {
        // Build some error string container here
        TypedDataSet.TypedDataRow row = tempSet.TypedDataTable.Single();
    
        var errors = from column in row.GetColumnsInError()
                     select row.GetColumnError(column);
    
        foreach (var error in errors)
        {
            // Add to error container here
        }
    }
    

    After this I check if my error container has any data in it. I suppose it makes sense for the column to retain value so that the programmer has access to that value and can include that it in the call to SetColumnError(…).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the following master.cs code: public partial class Default : System.Web.UI.MasterPage { protected void
Here is my code: public partial class Image : System.Web.UI.Page { protected void Page_Load(object
I have the following code: public partial class queryTerm : System.Web.UI.UserControl { private static
I have a Form class partial class ProgressMainForm : Form { public ProgressMainForm() {
public partial class Form1 : Form { string[] id; private void button_Click(object sender, EventArgs
I have a page containing a partial view with a list and a partial
I am currently learning WPF (C#) and have taken the following simple data binding
I have to XML (de)serialize the following class: this gives the following output: <ArrayOfPropertyFilter
when I run this code the Item-object in my CustomControl becomes a System.Windows.Data.Binding containing
public partial class MasterPages_Main : System.Web.UI.MasterPage { public string TopMenuTab; public string SubMenuTab; public

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.