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

Force Row Update with GridButton

3 Answers 57 Views
GridView
This is a migrated thread and some comments may be shown as answers.
David A.
Top achievements
Rank 1
David A. asked on 14 Mar 2011, 05:36 PM
Hi,
We have  not-so-technical users that don't understand moving off a row is what causes it to be added or updated.  Subsequently, I have added a button in each row that is to basically "save" the changes of the row (to the dataset).  I cannot seem to find a way to force the row to update as EndEdit and EndUpdate only seem to end a cell update.  I need something that will do the same thing as moving off a row so I can catch the errors in the RowValidating event.  Can you point me in the right direction?

Thank you.

3 Answers, 1 is accepted

Sort by
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 15 Mar 2011, 11:43 AM
Hello David,

I'd advise using Cell validation rather than Row validation for this. You can find out more by visiting this help topic.
I hope this helps but let me know if you need more information
Richard
0
Emanuel Varga
Top achievements
Rank 1
answered on 15 Mar 2011, 11:58 AM
Hello,

So, you can just put a dummy button and when the users click that button the cell and also the grid will loose focus, so changes will be applied, like so:

using System.Collections.Generic;
using System.Windows.Forms;
using Telerik.WinControls.UI;
 
public partial class Form1 : Form
{
    private RadGridView radGridView1;
    public Form1()
    {
        InitializeComponent();
        this.Controls.Add(radGridView1 = new RadGridView());
        radGridView1.Dock = DockStyle.Fill;
        radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
 
        var button = new RadButton();
        button.Text = "DummySave";
        button.Dock = DockStyle.Bottom;
        this.Controls.Add(button);
 
        var list = new List<Test>();
        list.Add(new Test{Id = 1, Name = "Name1"});
        list.Add(new Test{Id = 2, Name = "Name2"});
        radGridView1.DataSource = list;
    }
}
 
public class Test
{
    public int Id
    {
        get;
        set;
    }
 
    public string Name
    {
        get;
        set;
    }
}

Hope this helps, if you have any other questions or comments, please let me know,

Best Regards,
Emanuel Varga
Telerik WinForms MVP
0
David A.
Top achievements
Rank 1
answered on 16 Mar 2011, 08:03 AM
Thank you Richard and Emanuel.  Both of your suggestions were helpful.  I ended up using cell validation for this.
Tags
GridView
Asked by
David A.
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
Emanuel Varga
Top achievements
Rank 1
David A.
Top achievements
Rank 1
Share this question
or