Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have one gridview in that a link button is used for update. on click on update(Edit) it assign a value of selected row to respective text box .We can insert data dynamically by filling text boxes and then click on submit button.
the problem is that the submit button should use for both update and insert .
Posted
Comments
Maciej Los 9-Oct-15 1:45am    
What database? What have you tried? Where are you stuck?

1 solution

You should have some primary key field value in a HiddenField or something. So, if it is an existing record, you can get a Id which will be greater than 0, meaning a valid Id.

So, if Id is greater than 0, then update that record, else insert.
 
Share this answer
 
Comments
asplover1 9-Oct-15 0:04am    
But I want to insert and update record both on same submit button
That's what I said too. You need to store the Id of the field being inserted/updated. If Id is greater than 0, then in button click event, you can easily identify that it is an existing record. Otherwise it will be a new record.
asplover1 9-Oct-15 2:03am    
Ok got it. I will try it. Thank you
Great. After you solve it, please accept the answer. :)
asplover1 9-Oct-15 2:57am    
Thank very much. I done it. It works Properly.

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