ObjectDataSource and ColumnChanges.

W

Wayne Brantley

I have a grid connected to an ObjectDataSource and everything works and
updates fine. I am using VS2005's dataset designer to create the
dataset/tableadapters and developing in ASP.NET.

What I am now trying to do is to update column A when column B changes.
(This cannot be done at the SQL level as it requires resource not accessable
from SQL). So, I simply added a class to my project where I would extend
the DataTable class. Turns out that ColumnChanged event never gets called.
After further research, turns out that RowChanged event never gets called
with any action other than Add or Commit (but it does get called, so I know
my partial class extension and initialization was done right). So, it is
as if the ObjectDataSource never actually 'changes' any rows?

public partial class Dataset1{

public partial class DataTable1{

public override void BeginInit(){

this.RowChanged += new DataRowChangeEventHandler(Row_Changed);

this.ColumnChanged += new
DataColumnChangeEventHandler(Column_Changed);

base.BeginInit();

}

private void FontsDataTable_ColumnChanged(object sender,
DataColumnChangeEventArgs e){

string x = "est"; //Just random code, put a breakpoint here,
never called..

x = x + "test";

}

private void Row_Changed(object sender, DataRowChangeEventArgs e){

if (e.Action == DataRowAction.Change) { //This line will be
called, but action is never change...

string x = "est";

x = x + "test";

}

}

}

}



Wayne
 
K

Kevin Yu [MSFT]

Hi Wayne,

This code does not enter the event handle because the name of the delegate
isn't the one you specified. The one you added to the event handler is
Column_Changed. However, the one you defined. is
FontsDataTable_ColumnChanged. Change to the following might help.

public override void BeginInit()
{
this.RowChanged += new
DataRowChangeEventHandler(Row_Changed);

this.ColumnChanged += new
DataColumnChangeEventHandler(FontsDataTable_ColumnChanged);
base.BeginInit();
}

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
W

Wayne Brantley

Opps sorry about that. Not true, that is just a copy and paste bug when
creating this message. Obviously the code would not even compile if I had
that error. Anyway, I have the named delegate correct and the event does
NOT fire. Try it out on your own project and see!

Please let me know.

Thanks.
 
K

Kevin Yu [MSFT]

Hi Wayne,

Yes, I tried it on my machine. And your code works fine. Have you tried to
put these code into a simple app to see if it works fine? If it can be
reproed, can you send it to me by email? Remove 'online' from the no spam
alias is my email address.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top