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

I want to insert new data to database using GridDataBoundGrid

I'm very new to Syncfusion control.. help would Appreciation.

3 Replies

MS Maniratheenam Sehar Syncfusion Team May 15, 2014 03:57 AM UTC

HI Naresh ,

Thank you for your interest in Syncfusion products.

 We would like to help you by  our UG link  given below, by all means it will resolve your reported query.

UG Link: http://help.syncfusion.com/ug/windows%20forms/grid/default.htm#!documents/throughcode3.htm

Please let us know, if you have any further concerns.

Regards,

ManiRatheenam S



NA Naresh May 15, 2014 04:20 AM UTC

Maniratheenam Sehar,

thank you for your reply but i gone through it, still i did't figure it out is it possible to save new data to database from GridDataBoundGrid or else any other grids.
 with Thanks and Regards


MS Maniratheenam Sehar Syncfusion Team May 21, 2014 05:25 AM UTC

Hi Naresh,

Thank you for your patience.

  

Query:

Insert new data in GridDataBoundGrid

We would like to let you know that since the reported query can be viewed in many perspective. So, we have come up with solution which might resolve your reported query.

 

1.       To perform any changes in the GridDatabound control, you can make use of CommitChanges method and DirectSaveCellInfo property. Followinng codesnippet given below,

CODESNIPPET[C#]

       this.gridDataBoundGrid1.CommitChanges();

this.gridDataBoundGrid1.Binder.DirectSaveCellInfo = true;

Use DirectSaveCellInfo property to save once you complete editing a cell.

 

2.       SaveCellInfo Event

This event is used to store data back into your data source when it has been changed by the user. For your better convenience, we have provided an UG Link below,

http://help.syncfusion.com/ug/windows%20forms/grid/default.htm#!Documents/savecellinfoevent.htm

 

3.       If you are in need of save changes made in GridDataBound into database, then do refer the following procedure,

When the user makes changes in the grid, like editing a row, deleting a row or adding a new row, these changes are    immediately saved in the bound data set. There are two ways in which changes can be saved to the underlying database.

Option 1:

It is standard practice to include a Save button (or some other UI element) in the page which could be used by the user to confirm all the changes. And in the event handler for the Save button, you can call Update on the data adapter to force changes into the database:

 

CODESNIPPET[C#]

this.oleDbDataAdapter1.Update(this.dataSetCustomers1);

 

Option 2:

If the changes need to be saved into the database as soon as the user is done editing a row, deleting a row or adding a new row, then you can listen to the following events and call Update on the data adapter, as shown:

 

CODESNIPPET[C#]

// This will be called when the user edits or adds a new row.

private void GridGroupingControl1_CurrentRecordContextChange(object sender, Syncfusion.Grouping.CurrentRecordContextChangeEventArgs e)

{

if(e.Action == CurrentRecordAction.EndEditComplete)

{

this.oleDbDataAdapter1.Update(this.dataSetCustomers1);

}

}

// This will be called when the user deletes a row

private void GridGroupingControl1_BarButtonItemClicked(object source, Syncfusion.Web.UI.WebControls.Grid.Grouping.ButtonBarItemClickEventArgs e)

{

 if(e.ButtonBarItem.ButtonBarItemType==ButtonBarItemType.DeleteRow)

 {

  {

   Record curRecord = this.GridGroupingControl1.Table.CurrentRecord;

   curRecord.Delete();

   this.oleDbDataAdapter1.Update(this.dataSetCustomers1);

  }

  }

}

 

The above code is done using GridGrouping, you can perform the same using any of the gridcontrols.

 

Please let us know, if you have any further concerns.

 

Regards,

ManiRatheenam S

 


Loader.
Live Chat Icon For mobile
Up arrow icon