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,
AfterCellUpdate fires after the user makes a change to a cell and the the grid commits those changes to the underlying data source. When the change is committed is determined by the UpdateMode property. Updates can also be triggered in code via the Update method of the row or the UpdateData method of the grid.
I'm having a hard time understanding your question, though. Can you explain in more detail exactly what you want to do?
Hi Mike,
I have a screen like this (see below), so I would like to grap which column user updated (from TF_1 until TF_79) and the value it update, then i can direct assign into the update statement.
Let say I update row2 TF_3 to 2, then i able capture is TF_3 to variable column and 2 assign to variable value, then assign to "update table set ' "+column+" ' = ' "+value+" ' " something like that. then when i click arrow key --> to TF_4 then it will fire and run the update statement immediately.
Any function I can use to get the column name and also the value once it update (may update more than field) and any function should I use, once the field been modified and it will directly run the update function like I mention above.
Hope you able to understand what I trying to ask.
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.
I found the way for my problem. Thanks all.
Is solved now.
Thanks for all guidance ^^
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;