Update Cells in Datagridview - Linq to SQL
hi all,
i am binding datagridview with linqtosql query .
i want to edit information in current row in grid when i click on edit button in datagridview.
private
void dgTracker_CellClick(object sender, DataGridViewCellEventArgs e)
{
if
if(dgTracker.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name.ToString() == "imgEdit")
{
dgTracker.CurrentCell = dgTracker.Rows[e.RowIndex].Cells[4];
dgTracker.Rows[e.RowIndex].Cells[4].ReadOnly =
false;
dgTracker.BeginEdit(
true);
// // dgTracker.EndEdit();
blnEditFlag =
true;
MessageBox.Show( dgTracker.Rows[e.RowIndex].Cells[4].EditType.ToString());// = new string{ "Neeraj"};
//dgTracker.CurrentCell.Value = "Nb";
}
}
MessageBox.Show("cell value changed");
if (blnEditFlag == true)
{
db.SubmitChanges();
// db.Refresh(System.Data.Linq.RefreshMode.KeepChanges, rm);
}
the main problem is the value in current cell is not the new value which is modified and in case u check on cellleavevaluechnaged event the currentcell values it is still the old one.
and in case i need to change value of current cell mannually also it doesnt change it.
please help
NB- Moved byLingzhi SunMSFT, ModeratorThursday, October 22, 2009 8:00 AM (From:Application Compatibility for Windows Development)
All Replies
Hi NB,
The forum here is mainly for application development compatibility issues for different versions of Windows. I think LINQ to SQL forum would be more appropriate for the current issue.
How do you bind the LINQ to SQL query? Could you please provide some codes? If the query result is some anonymous type objects, I don’t think they are editable.
Have a nice day!
Best Regards
Lingzhi Sun
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.Hi NB,
How is the problem now? If you need further assistance, I recommend you post it at LINQ to SQL forum.
Have a nice day!
Best Regards,
Lingzhi Sun
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.- im used is BindingSource For any Edit in to DataGrid ...
if (dgTracker.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name.ToString() == "imgEdit") { ((ClassName)clientsBindingSource.Current).LastName = "Nik"; clientsBindingSource.EndEdit(); clientsBindingSource.ResetCurrentItem();
}


