Hi
I have an simple 2 level ultragrid. the updatemode is set to RowChangedOrLostFocus and the ultragrid'sdatqasource is set to a bindingsource which points to a datable in a strongly typed dataset.
the table has registred it's columnchanged event, the same is true for the grids BeforeExitEditMode
basically everything works, values get updated etc. and correctly transmitted to the database (later).but the the rowstate of my datarow is always unchanged even when I change a value the rowstate is unchanged in the table's ColumnChanged event and I don't know why, the rowstate should be "modified",shouldn't it?
is this normal behaviour, could something in the ultragrid causing this?
thanks
Hi,
My guess is that you must be checking the RowState on the wrong row or something. If RowState were not being updated, then you would not be able to update the data on the back end because the DataSet would not think anything changed and it would therefore not updated anything.
When exactly are you checking the RowState and how are you checking it?
Hi Mike,
I'm checking in the columnchanged event of my table. the event gets registered when I initialize my dataset and it also gets called, but won't go into the if clause because the rowstate is "unchanged"
like
public void Table_ColumnChanged(object sender, DataColumnChangeEventArgs e) { if(e.Row.RowState != DataRowState.Deleted && e.Row.RowState != DataRowState.Unchanged && !e.Column.AutoIncrement) { Delegate Del = Delegate.CreateDelegate(typeof(ValidationDelegate), e.Row, String.Format(VALIDATION_METHOD_MASK, e.Column.ColumnName), false, false); if(Del != null) { ValidationErrorObject Vae = ((ValidationDelegate)Del).Invoke(); if(Vae.IsValid) e.Row.SetColumnError(e.Row.Table.Columns[e.Column.ColumnName].ColumnName, ""); else e.Row.SetColumnError(e.Row.Table.Columns[e.Column.ColumnName].ColumnName, Vae.ErrorString); } } }
I don't think this has anything to do with the grid. I tried this out with some very simple sample code and I get the same results. All I did was create a form with a single button on it. Here's the code:
DataTable dt = new DataTable(); private void Form1_Load(object sender, EventArgs e) { this.dt.Columns.Add("A", typeof(int)); this.dt.Rows.Add(new object[] { 1 }); this.dt.Rows.Add(new object[] { 2 }); this.dt.Rows.Add(new object[] { 3 }); this.dt.AcceptChanges(); this.dt.ColumnChanged += new DataColumnChangeEventHandler(dt_ColumnChanged); } void dt_ColumnChanged(object sender, DataColumnChangeEventArgs e) { Debug.WriteLine(e.Row.RowState); } private void button1_Click(object sender, EventArgs e) { this.dt.Rows[0][0] = 10; }
When I push the button, ColumnChanged fires and the RowState of the row is Unchanged.
But, if I check the RowState in the button click event right after setting the field value, it comes back Modified. So it looks like the RowState is simply not updated at the time when ColumnChanged fires.
Hi Mike
Thank you very much for your effort :-)I appreciate it.
that's a very interesting thing, I assume I got around it until now by luck.I'll find another way like BeforeCellUpdate or AfterCellUpdate to achieve what I want.
Sometimes microsoft's events just don't make sense to me.