开发者

DataSet - RowChanged Event raised many Times?

开发者 https://www.devze.com 2023-02-16 22:49 出处:网络
I have this code : this.hRAddNewDataSet.Employee.RowChanged += new DataRowChangeEventHandler(Employee_RowChanged);

I have this code :

this.hRAddNewDataSet.Employee.RowChanged += new DataRowChangeEventHandler(Employee_RowChanged);

    void Employee_RowChanged(object sender, DataRowChangeEventArgs e)
    {
        test++;
        Trace.WriteLine(test.ToString());
    }

When I run my app and edit one row and then click the save button, the RowChanged event will fire 35 time!. I know this because of the value for test var.

My Questions:

开发者_JAVA技巧
  1. why this event fire like this?
  2. How I can get the current column is being updated?


why this event fire like this?

Perhaps you are wiring up the event handler multiple times?

Or maybe some part of your code is changing the row multiple times?

How I can get the current column is being updated?

Use the ColumnChanged event and check the DataColumnChangeEventArgs parameter.

0

精彩评论

暂无评论...
验证码 换一张
取 消