FormView Insert Session value

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • d-42

    FormView Insert Session value

    Hi,

    I'm trying to use FormView to Insert an Object to an ObjectDataSourc e.

    The insert method signature is simply:

    void DALObject.Inser tPerson(Person myObject)

    The person object for the sake of argument is:

    class Person {
    // properties:
    string FirstName // self explanatory
    string LastName
    long PersonID // "identity" (set by the database)
    long AccountID // a related account id, needs to be set
    }

    The formview collects first name, last name, etc, and when I hit
    insert, it automagically creates a Person object with the bound fields
    set..

    <InsertItemTemp late>
    First Name: <asp:TextBox ID="tbFirstNAme " runat="server"
    Text='<%# Bind("FirstName ") %>' /><br />
    ...etc for lastname, then buttons, etc...
    </InsertItemTempl ate>

    But one of the fields I need set is a session variable that contains
    the AccountID to use.

    How do I get it to create the object to be inserted and assign the
    AccountID to the session variable. An additional constraint is that I
    do not want the AccountID to be visible on the page.

    I'm stumped.

    The only thing I've thought of is to catch the OnInsertingEven t, but
    I'm not even really sure what to do with it. It doesn't give me the
    Person object its going to insert... just a dictionary of Property and
    Value pairs for the Person it will create to insert. I might be able
    to manually add a key pair ... to the dictionary? {AccountID,
    session"Account ID" } ?? Would that work? It seems pretty clumsy...

    Surely there is a better way?

    Thanks,
    Dave
  • d-42

    #2
    Re: FormView Insert Session value

    On Apr 16, 2:50 pm, d-42 <db.pors...@gma il.comwrote:
    Hi,
    >
    I'm trying to use FormView to Insert an Object to an ObjectDataSourc e.
    >
    The insert method signature is simply:
    >
    void DALObject.Inser tPerson(Person myObject)
    >
    The person object for the sake of argument is:
    >
    class Person {
    // properties:
    string FirstName // self explanatory
    string LastName
    long PersonID // "identity" (set by the database)
    long AccountID // a related account id, needs to be set
    >
    }
    >
    The formview collects first name, last name, etc, and when I hit
    insert, it automagically creates a Person object with the bound fields
    set..
    >
    <InsertItemTemp late>
    First Name: <asp:TextBox ID="tbFirstNAme " runat="server"
    Text='<%# Bind("FirstName ") %>' /><br />
    ...etc for lastname, then buttons, etc...
    </InsertItemTempl ate>
    >
    But one of the fields I need set is a session variable that contains
    the AccountID to use.
    >
    How do I get it to create the object to be inserted and assign the
    AccountID to the session variable. An additional constraint is that I
    do not want the AccountID to be visible on the page.
    >
    I'm stumped.
    >
    The only thing I've thought of is to catch the OnInsertingEven t, but
    I'm not even really sure what to do with it. It doesn't give me the
    Person object its going to insert... just a dictionary of Property and
    Value pairs for the Person it will create to insert. I might be able
    to manually add a key pair ... to the dictionary? {AccountID,
    session"Account ID" } ?? Would that work? It seems pretty clumsy...
    >
    Surely there is a better way?
    >
    Thanks,
    Dave
    Follow up... for the record, manually adding a key pair to the
    dictionary in the onInsertingEven t DOES work, but I still think its
    clumsy... and would like to know if there is a better way?

    Thanks again,
    Dave

    Comment

    Working...