DataGridView and DataSet , Update and AccpetChanges
C#
1
Posts
1
Posters
0
Views
1
Watching
-
Hi, the situation is this : i have a datagridview bound to a dataset. when i click on a button i've got on every datagridviewRow i need to update the changes in the same row, the thing is that i need also to change a column named "status" in the same row here is the event :
private void dgvCalibrtion\_CellContentClick(object sender, DataGridViewCellEventArgs e) { if( e.ColumnIndex == 6) { UpdateCalibrtionData((dgvCalibrtion.Rows\[e.RowIndex\].DataBoundItem as DataRowView).Row, e.RowIndex); TA\_CalibrationData.Update((dgvCalibrtion.Rows\[e.RowIndex\].DataBoundItem as DataRowView).Row); dS\_StationManager.T\_CalibrationData.AcceptChanges(); } }
the thing is that the change in the column status //Cell[2]// never send to the DB the Datagridview shows the string ("Valid", ... ) but does'nt pass the change to the *.mdb, Neither the color of the string is changed. but all the other manually changes to the datagridview ( input from user ) is updated o.k. //Here i'm changing the value of the cell myself//
private void UpdateCalibrtionData(DataRow dgvDataRow, int RowIndex) { DateTime ncalTime = (DateTime)dgvDataRow.ItemArray\[3\]; if (ncalTime < DateTime.Now) { dgvCalibrtion.Rows\[RowIndex\].Cells\[2\].Style.ForeColor = Color.Red; dgvCalibrtion.Rows\[RowIndex\].Cells\[2\].Value = "Date Expired"; return; } if (ncalTime > DateTime.Now) { if (ncalTime < DateTime.Now.AddDays(SM\_ApplicationData.Instance.CalibrationThreshold)) { TimeSpan dayDiff = (DateTime.Now - ncalTime); int dDays = -(dayDiff.Days - 1); dgvCalibrtion.Rows\[RowIndex\].Cells\[2\].Style.ForeColor = Color.Orange; dgvCalibrtion.Rows\[RowIndex\].Cells\[2\].Value = "will expire in" + dDays.ToString() + " Days"; return; } dgvCalibrtion.Rows\[RowIndex\].Cells\[2\].Value = "Still Valid"; dgvCalibrtion.Rows\[RowIndex\].Cells\[2\].Style.ForeColor = Color.Green; } }
any one??? :) :) :) Have a nice day
Have Fun Never forget it