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

Editing Record

Hi, Using Essential Suite v3.3.0.0, ASP.net v1.1 (VB.net) When I try to edit a record, Grid doesn''t save the changes and when it returns from postback it reset the record to the original state. I do the following steps: 1. Click on Record 2. Edit Record 3. Click on another record to save I tried to do the same code in C# and it works ok for the first postback, if I do another postback it reset the record to the original state. (sometimes C# code make the same VB.net behavior) I don''t think there is a relation between the language and this behaviour because it works well in the samples bundled in the suite (both VB.net and C# works well). I tried to make the same code in the samples but I get the same behavior. Regards, Bassam

11 Replies

AD Administrator Syncfusion Team October 18, 2005 09:01 PM UTC

Hi Bassam, 1.Editing Records: To enable editing you need to have a primary key column, so you need to add a PrimaryKeyColumn to the TableDescriptor before calling DataBind() as shown below to address this issue: [C#] //Add PrimaryKey to the PrimaryKeyColumns collection GridTableDescriptor mainTD = this.GridGroupingControl.TableDescriptor; mainTD.PrimaryKeyColumns.Add("CustomerID"); //Call DataBind this.GridGroupingControl.DataBind(); [VB] ''Add PrimaryKey to the PrimaryKeyColumns collection Dim mainTD As GridTableDescriptor = Me.GridGroupingControl.TableDescriptor mainTD.PrimaryKeyColumns.Add("CustomerID") ''DataBind Me.DataBind() 2. Saving changes to the Database: Take a look at this Knowledgebase article: http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=312 Regards Arun


BE Bassam El-Shafie October 19, 2005 02:29 PM UTC

Hi Arun, I forgot to mention that I do add a primary key to the tabledescriptor. Attached a sample to the mentioned behavior. Thanks, Bassam

GridEditTest.zip


AD Administrator Syncfusion Team October 19, 2005 09:46 PM UTC

Hi Bassam Yes, it is expected behavior as after a postback the Grid gets data from the database and since you have not saved the data to the database, it will get the old (unsaved) data. So as noted in the Knowledgebase Article you need to modify the sample to save the data to the database after you finish editing the row: private void GridGroupingControl1_CurrentRecordContextChange(object sender, Syncfusion.Grouping.CurrentRecordContextChangeEventArgs e) { if(e.Action == CurrentRecordAction.EndEditComplete) { this.products.Update(this.ds1); } } I tried this in the sample you sent and it worked fine. Can you try this and let us know if you have any further questions. Regards Arun


BE Bassam El-Shafie October 20, 2005 03:56 AM UTC

Hi Arun, I tried products.update (as you told me) but I get the same behavior, I even tried to get the new values ex.: ((Syncfusion.Grouping.Record)e.Record).GetValue("ProductName") but it returns the old value. Regards, Bassam


AD Administrator Syncfusion Team October 20, 2005 08:03 PM UTC

Hi Bassam Can you replace the files in the /cs folder of the sample you uploaded with these files and then try running the CS sample. Also can you put a Stop in GridGroupingControl1_CurrentRecordContextChange and ensure that it gets hit after you modify the row and move out. Regards Arun


BE Bassam El-Shafie October 22, 2005 12:40 PM UTC

Hi Arun, It worked in CS but not in VB. Attahced the full sample after inserting the files you sent. Regards, Bassam

GridEditTest2.zip


BE Bassam El-Shafie October 22, 2005 12:46 PM UTC

PS:


BE Bassam El-Shafie October 22, 2005 12:50 PM UTC

Sorry for last msg (by mistake) I''ve put a break point at products.update line, and it breaks in both cs and vb. I checked the new value in the vb but got the old one. Regards, Bassam


AD Administrator Syncfusion Team October 24, 2005 02:41 PM UTC

Hi Bassam, 1. Here is a modified version of the VB.NET sample. Unzip it to the ..Syncfusion\Essential Studio\3.3.0.0\Web\Grid.Grouping.Web\Samples\1.1\cust\VB or modify the VB.vbproj.webinfo file accordingly and create an application directory in IIS. Let us know if this sample works fine. 2. I have deployed the above sample here. You should be able to edit records and the changes are reflected in the database. Regards Arun


BE Bassam El-Shafie October 24, 2005 10:33 PM UTC

Hi Arun, Your sample works perfectly, but can you tell me whats the modification you made to make it works? cause I really gave up. I cant see any difference between yours and the code I sent before. I made everything like it but no use. Regards, Bassam


AD Administrator Syncfusion Team October 25, 2005 01:45 PM UTC

Hi Bassam The only difference is that I replaced: grid.TableDescriptor.PrimaryKeyColumns.Add("ProductID"); with this.GridGroupingControl1.TableDescriptor.PrimaryKeyColumns.Add("ProductID"); Note that you need not add a Primary key if you are using the 1.x version of the .NET Framework. Also take a look at the various samples that ship with Essential Grid. You can follow the Knowledgebase article to set up editing the updating the underlying datasource that the Grid is bound to. Regards Arun

Loader.
Live Chat Icon For mobile
Up arrow icon