G
Guest
I have a standard typed dataset (.net 2005). And created a separete class
file to handle the RowChanging event. The dataset name is dalCadastro and the
datatable is pessoa. The code I wrote to extend the dataset and handle the
event is as follows:
public partial class dalCadastro
{
public partial class pessoaDataTable
{
public override void BeginInit()
{
base.BeginInit();
this.RowChanging +=
new DataRowChangeEventHandler(Validate);
}
void Validate(object sender, DataRowChangeEventArgs e)
{
throw new Exception("Can not change!");
}
}
}
It compiles OK. But when the page is loaded, the exception I created was
thrown. Why if the event is only when a column is changing ?
I tried to test if( e.Row.RowState == DataRowState.Modified ), but not
works. The state is allways Detached ... Even if I issued the update.
I tried test if (e.Action == DataRowAction.Change), but do not work too.
I'm using a form view and a object datasource configured to use this typed
dataset. All select, insert, delete and update works fine, but the Event
handling not.
What is the correct form for this type of event handling or what
verifications I need to do in the event handler code ?
I tried several internet samples, but none work, even compile.
An observation, the code was writen with the help of the VS 2005 IDE when
i'm was typing the code.
What is the solution please ?
--- I tried a more strongly typed handling (that is possible in VS 2005) ...
but the same behavior continues:
public partial class dalCadastro
{
public partial class pessoaDataTable
{
public override void BeginInit()
{
base.BeginInit();
Here-->> this.pessoaRowChanging += new
pessoaRowChangeEventHandler(Validate);
}
void Validate(object sender, -->> Here pessoaRowChangeEvent e)
{
throw new Exception("Cannot change");
}
}
}
file to handle the RowChanging event. The dataset name is dalCadastro and the
datatable is pessoa. The code I wrote to extend the dataset and handle the
event is as follows:
public partial class dalCadastro
{
public partial class pessoaDataTable
{
public override void BeginInit()
{
base.BeginInit();
this.RowChanging +=
new DataRowChangeEventHandler(Validate);
}
void Validate(object sender, DataRowChangeEventArgs e)
{
throw new Exception("Can not change!");
}
}
}
It compiles OK. But when the page is loaded, the exception I created was
thrown. Why if the event is only when a column is changing ?
I tried to test if( e.Row.RowState == DataRowState.Modified ), but not
works. The state is allways Detached ... Even if I issued the update.
I tried test if (e.Action == DataRowAction.Change), but do not work too.
I'm using a form view and a object datasource configured to use this typed
dataset. All select, insert, delete and update works fine, but the Event
handling not.
What is the correct form for this type of event handling or what
verifications I need to do in the event handler code ?
I tried several internet samples, but none work, even compile.
An observation, the code was writen with the help of the VS 2005 IDE when
i'm was typing the code.
What is the solution please ?
--- I tried a more strongly typed handling (that is possible in VS 2005) ...
but the same behavior continues:
public partial class dalCadastro
{
public partial class pessoaDataTable
{
public override void BeginInit()
{
base.BeginInit();
Here-->> this.pessoaRowChanging += new
pessoaRowChangeEventHandler(Validate);
}
void Validate(object sender, -->> Here pessoaRowChangeEvent e)
{
throw new Exception("Cannot change");
}
}
}