How to differentiate updating or inserting in GridView OnUpdating Event?

unarveDeavy

New Member
I'm working on my Web Application using ASP.NET, I came into a situation where I need to differentiate UPDATIng and INSERTING on GridView Updating Event. \[code\] protected void GridView_RowUpdating(object sender, GridViewUpdateEventArgs e) { //conditional check if(Update Flage){ //Call Update Function } else{ //Call Insert Function } }\[/code\]I have a ItemTemplate and EditItemTemplate in the GridView, when click on Edit Button (on ItemTemplate), then change to Update Button (on EditItemTemplate).
wXdPV.jpg
And I have a Add Button outside of GridView, upon clicking, add a new Row into GridView and change Button text to ADD as following code fragment:\[code\]ds.Tables[0].Rows.InsertAt(ds.Tables[0].NewRow(), 0);GridViewID.EditIndex = 0;LinkButton cmdButton = GridView.Rows[0].FindControl("btnUpdate") as LinkButton;cmdButton.Text = "Add";\[/code\]I know there is InsertItemTemplate for row inserting, but in my situation I was using Button outside of GridView to add new editing row instead.So, how can I differentiate editing or inserting on RowUpdating Event? Any recommended trick to achieve this? perhaps something like adding a HiddenField as a flag.Thank you in advanced.
 
Back
Top