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.
Unfortunately, activation email could not send to your email. Please try again.

Changing Data in DataTable.RowChanged - Event with bounded ggc

Thread ID:

Created:

Updated:

Platform:

Replies:

41290 Feb 27,2006 09:31 AM Mar 2,2006 08:19 AM Windows Forms 6
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On February 27, 2006 09:31 AM

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

stanleyj [Syncfusion]
Replied On February 27, 2006 09:49 AM

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

Administrator [Syncfusion]
Replied On February 28, 2006 03:29 AM

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

stanleyj [Syncfusion]
Replied On February 28, 2006 04:09 AM

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

Administrator [Syncfusion]
Replied On February 28, 2006 04:49 AM

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

stanleyj [Syncfusion]
Replied On March 2, 2006 07:30 AM

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

Administrator [Syncfusion]
Replied On March 2, 2006 08:19 AM

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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;