Hi all,
I have a ultragrid with 80+column, so I use the KeyDown function to make it able to move like excel with ArrowKey and also mouse. To convinient for modify, I would like to let them direct key in and modify then when move to next field and direct update the previous updated value into DB.
How can I grap which cell/field which been modified? Because I want to allow them to update field by mouse clicking to it and also keyboard arrowkey, so I wasnt sure which function is more suitable for this scenario.
Please guide.
Thank you very much!
If I understood you correctly then the UpdateMode property would be useful in your scenario. With the line of code pasted below, it will commit the changes to the data source when the user leaves a modified cell.
ultraGrid1.UpdateMode = UpdateMode.OnCellChange;
Hi Torrey,
Thanks for reply. The function you mention able to capture more than 1 field with the column name and also the value? because I need to capture the column name also the value for my update query, so only those field been modified will be updated.
I had done some research online, notice that most of them using AfterCellUpdate, will it suitable for my case? If possible, can you explain with example how does it work?
Thank you very much!~
Hi,
It depends on what kind of information you want to track and exactly when you are trying to use that information. But it sounds like what you are trying to do is track any changes that are made to the data so that you can build an Update command for your data source. In other words, you are concerned with the updating of the back end by the data source.
The grid is really not involved in this process. The grid only deals with it's local DataSource. The interaction between the DataSource and the back end is something that is typically handled outside the grid.
What kind of DataSource are you using for your grid? If you are using a DataSet or DataTable, then these objects track all changes for you, and the DataAdapter can utilize this information and build your SQl statements for you.
If you are using some other data source, then you need to investigate what kind of support that data source has for tracking changes.
If you really have to, you could build a list of changes yourself by using the events of the grid. But this assumes that the grid is the only thing that will ever change the data. And there is no functionality built-in to the grid to do this for you.
Im using UltraWinDataSource
UltraDataSource doesn't have any back end, it only exists in the client. So it does not track changes.
But I think I am probably not understanding your question. Leaving a cell in the grid will automatically write any changes to the data source. This depends on the UpdateMode property, but updating on a cell change is the default.
I don't think I understand your question or what you are trying to do.
Hi Mike,
I try to get the updated cell with AfterCellUpdate and assign it into variable as part of my update statement, but it execute the update until the application "no respone". Please point out my mistake for better improvement.
private void ugLisfOfVolMaint_AfterCellUpdate(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
{ // AfterCellUpdate gets fired after the cell's value has been changed in the UltraGrid.
const string METHOD_NAME = "mnuShowStructure_Click";
Cursor oldCursor = Cursor.Current;
Cursor.Current = Cursors.WaitCursor;
string strSQL, svolID = "", svolLine = "", srouteID = "",sheader ="", svalue ="";
try
{
svolID = ugLisfOfVolMaint.ActiveRow.Cells["vol_id"].Value.ToString();
svolLine = ugLisfOfVolMaint.ActiveRow.Cells["vol_line_id"].Value.ToString();
srouteID = ugLisfOfVolMaint.ActiveRow.Cells["Route_ID"].Value.ToString();
sheader = e.Cell.Column.ToString();
svalue = e.Cell.Value.ToString();
strSQL = "update ras_vol_wafer set " + sheader + " = '" + svalue + "', last_update = sysdate " +
" where vol_id = '" + svolID + "' and vol_line_id = '" + svolLine + "' and rrth_id = '" + srouteID + "' ";
MyDBConn.ExecuteNonQuery(ModGloVariable.RasmusConn, CommandType.Text, strSQL);
}
catch (Exception ex)
ModProc.ShowSysErrMsg(ex.Message, METHOD_NAME, CLASS_NAME);
finally
Cursor.Current = oldCursor;
I found the way for my problem. Thanks all.