Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
465
WinGrid and LINQ to SQL - events to decide edit mode
posted

Hi,

I am writing application with MSSQL and LINQ to SQL ( C#3.0 and .NET 3.5 ).
I am using WinGrid and data from LINQ to SQL.

//Create an instance of the NorthWindDataContext
NorthWindDataContext db = new NorthWindDataContext(connectstring);

//Select all products in the database where the category name is Beverages
var products = from p in db.Products
select p

//Bind WinGrid to the results
this.WinGrid.DataSource = products;

I have WinGrid with linked RowEditTemplate to the grid. I have separate Insert / Update / Delete
( Storage Procedure ) linked to the LINQ to SQL.
 
My question is, which event of WinGrid ( or EditTemplate ) is the best to put
Insert / Update / Delete logic ?
Right now I can not find any way to decide if row was added , modified or deleted when I am trying
to save data to the database.

Regards
Peter
Parents
No Data
Reply
  • 37774
    Verified Answer
    posted

    Peter,

    You can look at either the AfterCellUpdate or AfterRowUpdate to handle edits and AfterRowsDeleted to handle deleted rows.  You may want to handle the AfterRowUpdate event for insertions as well, since the AfterRowInsert will fire if you use the TemplateAddRow and simply click into it; what you would do in this case is query the DataContext to see if there is already a row in the table with the relevant keys of the row and if not, add it, otherwise update it.

    -Matt

Children
No Data