I have a radgridview on a winform that is bound to a tableadapter.
I have the following code in the CellEndEdit Event:
The problem is when I click the "Click here to Add a New Row" and fill in the row, the Adapter.Update gets called but nothing is inserted into the database when I leave the row. I can step through the code and it steps over the Update, and no error is raised - yet there is no data in the database. If I navigate off of the row, then navigate BACK to the row and update it, then the
INSERT command is fired cause I can see it in the database when I do a trace.
So what I need to know is where is the right place to put a call to the Adapter.Insert Method? I don't know what event to use.
I know I can create a new set of textboxes and checkboxes tro mimic my record and have a "Click to INsert" button with some code behind that, but I want to use the default functionality of the RadGrid.
Having said that - what is the recommended way to bind radGridViews to a SQL database? I use TableAdapters because I come from an ASP .NET background and they work well there - but is there a better way to do it in Winforms? Should I be using LINQ?
I have the following code in the CellEndEdit Event:
private void grdPeople_CellEndEdit(object sender, GridViewCellEventArgs e)
{
try
{
this.Validate();
this.peopleBindingSource.EndEdit();
this.peopleTableAdapter.Update(peopleDAL);
}
catch (System.Exception ex)
{
MessageBox.Show("Update failed:"+ex.Message);
}
}
The problem is when I click the "Click here to Add a New Row" and fill in the row, the Adapter.Update gets called but nothing is inserted into the database when I leave the row. I can step through the code and it steps over the Update, and no error is raised - yet there is no data in the database. If I navigate off of the row, then navigate BACK to the row and update it, then the
INSERT command is fired cause I can see it in the database when I do a trace.
So what I need to know is where is the right place to put a call to the Adapter.Insert Method? I don't know what event to use.
I know I can create a new set of textboxes and checkboxes tro mimic my record and have a "Click to INsert" button with some code behind that, but I want to use the default functionality of the RadGrid.
Having said that - what is the recommended way to bind radGridViews to a SQL database? I use TableAdapters because I come from an ASP .NET background and they work well there - but is there a better way to do it in Winforms? Should I be using LINQ?