Click here to Skip to main content
16,021,172 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi
i have two methods

C#
private void insertrow()
{

}



private void updaterow()
{

}



i want to these two differnt methods in save button click


C#
protected void BtnSave_Click(object sender, EventArgs e)
{
}

ie if iam inserting a new record i want to call inserrow();
ootherwise if editing existing record i will updaterow ..?
Any Help..?/
Posted
Comments
[no name] 20-Jul-12 9:02am    
Are you serious?
shashavali 20-Jul-12 9:05am    
yeahh very seriousm !!1
[no name] 20-Jul-12 11:28am    
Time to think of a new career then.
[no name] 20-Jul-12 9:12am    
A repost and you already had an answer.
bbirajdar 20-Jul-12 9:27am    
repost - http://www.codeproject.com/Questions/425237/how-perform-both-operations-such-as-inserting-and

1 solution

You need to add some way to know if you are inserting or updating. Create a flag, such as IsNew.
C#
protected void BtnSave_Click(object sender, EventArgs e)
{
  if (IsNew)
  {
    insertrow()
  }
  else
  {
    updaterow()
  }
}
 
Share this answer
 
Comments
shashavali 23-Jul-12 6:47am    
thanks

can u please explain me how to set a flag.
ZurdoDev 23-Jul-12 7:41am    
It will depend on how you have your page setup. How does the user know if they are inserting instead of updating?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900