We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Changing Data in DataTable.RowChanged - Event with bounded ggc

I''m running in a serious problem while adding new data to ggc. The constelation is a little bit hard to describe but at least there is a dataset with several hierarchic related tables, and a ggc. In the dataTables I handle the RowChanged event where i have to change some values of the current changed record to the correct value. In my case the id of the record is set to a new value. Private Sub BasicSystemDTE_RowChanged(ByVal sender As Object, ByVal e As System.Data.DataRowChangeEventArgs) Handles MyBase.RowChanged Select Case e.Action Case DataRowAction.Add ''write new id to record e.Row.Item(Decl.allTableCols.id.ToString) = Now.Millisecond ''<- dummyvalue End Select End Sub After leaving the event-handler I earn (depending on the selection-mode) several handled exceptions. Sometimes there pops up an annoyingh message box with an "object is not set to an instance" message and so on. The listViewSelection-mode is worse then the normal selecten mode but there are exceptions with both of them. Is there a chance to prevent the exceptions? I tried the last hours a lot of things like supending layout and events. Searching for possibilities to unbind datasource from ggc during update and so on ... but no success. I do not understand how the selection mode can have any infuence to that behavior The funny thing is that the result of the update is absolutely correct. If there where no exceptions I had no problem. Maybe someone has any ideas? Greets, Klaus

6 Replies

ST stanleyj Syncfusion Team February 27, 2006 02:49 PM UTC

Hi Klaus, Can you please check if ignoring exceptions through ResumeCatchExceptions helps. using Syncfusion.Windows.Forms; ExceptionManager.ExceptionCatched += new ExceptionCatchedEventHandler(ExceptionManager_ExceptionCatched); void ExceptionManager_ExceptionCatched(object sender, ExceptionCatchedEventArgs e) { ExceptionManager.ResumeCatchExceptions(); } Best regards, Stanley


AD Administrator Syncfusion Team February 28, 2006 08:29 AM UTC

Hi Stanley, thank you for all the help that you provide to us. In the current issue I tried ExceptionManager.ResumeCatchExceptions whereby no further (sometimes) messageboxes pops up, but the handled exeptions are still occurs. I know that handled exceptions are not that bad, but they are also annoying. And I thing there could be a small but in the control. I extracted a very small sample (VS 2003) project where you can see the exception when you set your debugging setting to "step into debugger for common language runtime exceptions" You will see an IndexOutOfRangeException when you enter any value to a new row. Please take a look at the event handler "DataTableExt_RowChanged" where i write a new value. If I do not write a value there is no exception. Hope you have time to take a look. Greetings, Klaus >Hi Klaus, > >Can you please check if ignoring exceptions through ResumeCatchExceptions helps. > > >using Syncfusion.Windows.Forms; > >ExceptionManager.ExceptionCatched += new ExceptionCatchedEventHandler(ExceptionManager_ExceptionCatched); > > >void ExceptionManager_ExceptionCatched(object sender, ExceptionCatchedEventArgs e) >{ >ExceptionManager.ResumeCatchExceptions(); >} > >Best regards, >Stanley >

RowChangedUpdateBug.zip


ST stanleyj Syncfusion Team February 28, 2006 09:09 AM UTC

Hi Klaus, You can implement adding a default values for certain columns with the CurrentRecordContextChange handler. Please refer this thread and let us know if that does not helps. http://www.syncfusion.com/support/forums/message.aspx?MessageID=39861 Best regards, Stanley


AD Administrator Syncfusion Team February 28, 2006 09:49 AM UTC

Hi Stanley, I already know the possibilities of setting a default value e.g. in RecordContextChanged event. But my design of the application is that there are several controls(differnt views) that are all bound to the same (sigle) DataSet. The DataSet and its DataTables gets and sets its data via an object-API. The object-API holds a connection to the database. When the user now enter a new record in the ggc the DataSet creates a new object via the object-API and stores the new object to the database. While the object is stored a new primary key is created on the database that is the return value of the store-function. Only after calling the store-function I''m able to set the primary-key to the new record. And the best place for that is the row changed event of the DataTable. Otherwise all bound controls have to implement the creation of new rows for its own. Have you got the handled exception with my sample? Is there a minor bug? Best regards, Klaus >Hi Klaus, > >You can implement adding a default values for certain columns with the CurrentRecordContextChange handler. Please refer this thread and let us know if that does not helps. > > >http://www.syncfusion.com/support/forums/message.aspx?MessageID=39861 > > >Best regards, >Stanley


ST stanleyj Syncfusion Team March 2, 2006 12:30 PM UTC

Hi Klaus, Sorry for the delayed response. Adding datarow''s BeginEdit before making changes to a column clears this problem. Can you please check from your end. Private Sub DataTableExt_RowChanged(ByVal sender As Object, ByVal e As System.Data.DataRowChangeEventArgs) Handles MyBase.RowChanged Select Case e.Action Case DataRowAction.Add ''write new id to record e.Row.BeginEdit() ''Added line e.Row.Item(Decl.allTableCols.id.ToString) = Now.Millisecond ''e.Row.Item(Decl.basicSystemCols.description.ToString) = "hugo " & Now.Millisecond End Select End Sub Thanks for the sample. Best regards, Stanley


AD Administrator Syncfusion Team March 2, 2006 01:19 PM UTC

Hi Stanley, big thank you for the investigation! It works now without exception ;-) I alrady tried with row.BeginEdit() - but I always called a row.EndEdit() to. Thanks, Klaus

Loader.
Live Chat Icon For mobile
Up arrow icon