0

In my webpage, I have a button "SAVE DRAFT". The first time it is clicked the record must be inserted and the text of the button would be changed as "Update Draft". Then how manytimes the button is hit, it should just update the record. However if the user goes from that page and enters this page again it should go back to "save draft" and rec insertion. How can I do this?

3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by msaranya
1

You could save the primary key in hidden fields on the web form after the initial save. If the value of the primary key is null or blanks (which is an invalid value for a primary key) you know that the record needs to be inserted. If it contains a value, you know you need to update the record. This will also ensure that you have the primary key available for the Update process.

The nature of web pages should guarantee that if you navigate away from this page and then back to this page from another page that this will always be true (except, maybe, if they used the back button on the browser).

You could add an extra piece of mind by clearing the primary key field in teh page load when Not Page.IsPostBack.

0
if(primary<>0)
{
Update()
}
else
{
add()}
}

Thanks

Edited by peter_budo: Keep It Clear - Do wrap your programming code blocks within [code] ... [/code] tags

0

You could save the primary key in hidden fields on the web form after the initial save. If the value of the primary key is null or blanks (which is an invalid value for a primary key) you know that the record needs to be inserted. If it contains a value, you know you need to update the record. This will also ensure that you have the primary key available for the Update process.

The nature of web pages should guarantee that if you navigate away from this page and then back to this page from another page that this will always be true (except, maybe, if they used the back button on the browser).

You could add an extra piece of mind by clearing the primary key field in teh page load when Not Page.IsPostBack.

Thanks... Ur idea did the trick!!!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.