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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

I want to insert new data to database using GridDataBoundGrid

Thread ID:

Created:

Updated:

Platform:

Replies:

116312 May 14,2014 05:12 AM UTC May 21,2014 05:25 AM UTC WinForms 3
loading
Tags: GridDataBoundGrid(Classic)
Naresh
Asked On May 14, 2014 05:12 AM UTC

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

Maniratheenam Sehar [Syncfusion]
Replied On 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


Naresh
Replied On 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

Maniratheenam Sehar [Syncfusion]
Replied On 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

 


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.

Warning Icon 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.Close Icon

;