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

How do I update a cell value

4 Answers 926 Views
GridView
This is a migrated thread and some comments may be shown as answers.
SarperSozen
Top achievements
Rank 1
SarperSozen asked on 01 Feb 2017, 10:22 AM

I am using RadGridView. I insert datas to RadGirdView like this:

// I am using Lambda Expression to get datas from Database.
var o = _vt.persons;
radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
radGridView1.Columns.Clear();
radGridView1.Rows.Clear();
radGridView1.MasterTemplate.AllowAddNewRow = false;
radGridView1.Columns.Add(new GridViewDecimalColumn("No"));
radGridView1.Columns.Add(new GridViewTextBoxColumn("Puanı"));
radGridView1.Columns.Add(new GridViewTextBoxColumn("Sonuç"));
radGridView1.Columns[0].Width = 8;
radGridView1.Columns[0].ReadOnly = true;
{
    var enumerable = o.ToArray();
    foreach (var m in enumerable)
    {
        var r = radGridView1.Rows.AddNew();
        r.Cells[0].Value = m.no;
        r.Cells[0].Tag = "no";
 
        r.Cells[1].Value = m.puani;
        r.Cells[1].Tag = "puani";
 
        r.Cells[2].Value = m.sonuc;
        r.Cells[2].Tag = "sonuc";
    }
}
radGridView1.ClearSelection();
radGridView1.CurrentRow = null;

You knoew, when double-click on a cell, it forms to editable mode. You enter a new value an when you click anywhere on the form or click enter, new value appears in the cell. But when I lick anywhere on the form or click enter, I want to save new value to the database. For this, I am using CellEndEdit event, but I did not manage to save new value to database.

 

Kind regards,

Mehmet.

 

4 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 01 Feb 2017, 11:33 AM
Hello Mehmet,

Thank you for writing.  

It is appropriate to handle the CellValueChanged event which is fired immediately after the user edits a single cell. I would recommend you to have a look at the following help article which demonstrates how to update the database: http://docs.telerik.com/devtools/winforms/gridview/populating-with-data/updating-the-database-with-ado.net

I hope this information helps. Should you have further questions I would be glad to help.

Regards,
Dess
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
SarperSozen
Top achievements
Rank 1
answered on 01 Feb 2017, 11:44 AM

Dess, firstly thnak you very much. RadGridView is filled datas from database while Form loading. And CellValueChanged event is fired while loading datas on Form loading too. For eample if we have 36 pieces of data, CellValuChanged is fired 36 times. So I decided to use CellEndEdit. Is there any solution about tihs situation?

For updating, I will try soon.

Kind regards,

Mehmet.

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 02 Feb 2017, 10:13 AM
Hello Mehmet,

Thank you for writing.  

If you add the rows in RadGridView programmatically in unbound mode, I would recommend you to subscribe to the CellValueChanged event after the grid is populated with data. Thus, the event will be fired when you really update the cell's value and update the database accordingly.

I hope this information helps. Should you have further questions I would be glad to help.

Regards,
Dess
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
SarperSozen
Top achievements
Rank 1
answered on 12 Feb 2017, 10:02 PM

I took a break because I had to work for a PhD qualification exam. I hope to try again later and write down the result here.

So glad I have you

Mehmet.

Tags
GridView
Asked by
SarperSozen
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
SarperSozen
Top achievements
Rank 1
Share this question
or