locked
How to implement save and update with a single button in asp .net........... RRS feed

  • Question

  • User-1085346629 posted

    Hai all,

    how to create save and update by using a single button in asp .net...Is it possible to create. I mean if we open create page we can enter the details and save the data.. if we need to modify the data while clicking the modify button it will redirect the same page button insted of save button we should get update button is it possible...please give me suggession ..

    please send me any reference code or notes..........

    Thanks In Advance.........

    RUPESH KURA

    Tuesday, August 7, 2012 1:47 AM

Answers

  • User-1629691846 posted

    You can check whether the primary key field or the unique id field is exist or not for the record you are savind/updating,

    if it exist the you need fire update query otherwise fire the Save query.

    If(IdFiledValueExist)

    {

    //Update Query

    }

    Else

    {

    //Save Query

    }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 7, 2012 1:53 AM
  • User-952121411 posted

    (2) very streamlined ways to this goal would be the following IMO:

    1. Use an 'EntityDataSource' control bound to your form that will actually persist data without any code behind needed.
    2. Use ASP.NET MVC and Entity Framework. When you leverage model binding capabilities of MVC and EF, you can persist data in about 3 lines of code in the controller.
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 8, 2012 11:28 AM

All replies

  • User-1629691846 posted

    You can check whether the primary key field or the unique id field is exist or not for the record you are savind/updating,

    if it exist the you need fire update query otherwise fire the Save query.

    If(IdFiledValueExist)

    {

    //Update Query

    }

    Else

    {

    //Save Query

    }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 7, 2012 1:53 AM
  • User-952121411 posted

    (2) very streamlined ways to this goal would be the following IMO:

    1. Use an 'EntityDataSource' control bound to your form that will actually persist data without any code behind needed.
    2. Use ASP.NET MVC and Entity Framework. When you leverage model binding capabilities of MVC and EF, you can persist data in about 3 lines of code in the controller.
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 8, 2012 11:28 AM