locked
Adding Behaviour using Linq to SQL to a Dynamic Data Custom Page RRS feed

  • Question

  • User-1336852631 posted

    I have a dynamic data web site and I need to add some custom behaviour to one of the Edit pages.

    I've created a custom page for one of the entities and want to add a button that will execute a Linq to SQL query that updates the database using some values from the Edit page.

    As the Edit page was dynamically generated what syntax do I use to access fields from the record being edited on the Edit page in my Linq to SQL query?

    Monday, May 21, 2012 10:53 AM

Answers

  • User-330204900 posted

    Hi Biga,getting at the data in the page can be difficult however if you add a custom button to the FormView with a command type of Update/Insert you can then get access to the updated values in the updateing/Inserting event you can test for

    protected void FormView1_ItemUpdating(object sender, FormViewUpdateEventArgs e)
    {
        if (e.CommandArgument == "DoSomething")
        {
            var values = e.NewValues;
            // do your stuff...
            e.Cancel = true;
        }
    }

    where "DoSomething" is the command argument that you set so you can differentiate you custom button from the normal Update/Insert button, and then when you are done set e.Cancel to true and the update will abort after doing your custom thing.

    where you

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, May 21, 2012 11:09 AM

All replies

  • User-330204900 posted

    Hi Biga,getting at the data in the page can be difficult however if you add a custom button to the FormView with a command type of Update/Insert you can then get access to the updated values in the updateing/Inserting event you can test for

    protected void FormView1_ItemUpdating(object sender, FormViewUpdateEventArgs e)
    {
        if (e.CommandArgument == "DoSomething")
        {
            var values = e.NewValues;
            // do your stuff...
            e.Cancel = true;
        }
    }

    where "DoSomething" is the command argument that you set so you can differentiate you custom button from the normal Update/Insert button, and then when you are done set e.Cancel to true and the update will abort after doing your custom thing.

    where you

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, May 21, 2012 11:09 AM
  • User-1336852631 posted

    Thanks very much Steve - that works fine.

    Monday, May 21, 2012 12:48 PM
  • User-330204900 posted

    Always welcome :)

    Monday, May 21, 2012 5:35 PM