This is a migrated thread and some comments may be shown as answers.

Updating Database Table Automatically when changes are made in gridview which is bounded to it.

1 Answer 425 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Rakesh
Top achievements
Rank 1
Rakesh asked on 04 Aug 2010, 07:35 AM
I am not able to update/insert/delete the data of database table which is bounded to a radgridview by selecting the Data Source for it.
The changes which i make in the gridview, i want that to be reflected in the database table automatically or on a button click, which i could not so please help me and give me code for it in c#.
The database I am using is Sql. 

1 Answer, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 06 Aug 2010, 03:58 PM
Hi Rakesh,

The RadGridView control not support this functionality automatically. The grid control bounds and renders different types of data and load/save logic from databases and other storages is implemented as business logic of the developed application.

If you are using DataTable and TableAdapter to retrieve and update data from a SQL Server database in a button click handler use this code snippet:

public partial class Form6 : Form
{
    public Form6()
    {
        InitializeComponent();
    }
 
    private void Form6_Load(object sender, EventArgs e)
    {
        // TODO: This line of code loads data into the 'northwindDataSet.Customers' table. You can move, or remove it, as needed.
        this.customersTableAdapter.Fill(this.northwindDataSet.Customers);
 
        this.radGridView1.DataSource = this.northwindDataSet.Customers;
        
    }
 
    private void radButton1_Click(object sender, EventArgs e)
    {
        this.customersTableAdapter.Update(this.northwindDataSet.Customers);
    }
}

Sincerely yours,
Julian Benkov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Rakesh
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Share this question
or