|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
ObjectDataSource and ColumnChanges.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 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." 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. Show quote "Kevin Yu [MSFT]" <v-k***@online.microsoft.com> wrote in message news:PbHdEW$HGHA.3152@TK2MSFTNGXA02.phx.gbl... > 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." > 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."
Other interesting topics
|
|||||||||||||||||||||||