Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / April 2008

Tip: Looking for answers? Try searching our database.

FormView Insert Session value

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
d-42 - 16 Apr 2008 22:50 GMT
Hi,

I'm trying to use FormView to Insert an Object to an ObjectDataSource.

The insert method signature is simply:

void DALObject.InsertPerson(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..

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

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 OnInsertingEvent, 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"AccountID" } ?? Would that work? It seems pretty clumsy...

Surely there is a better way?

Thanks,
Dave
d-42 - 17 Apr 2008 01:37 GMT
> Hi,
>
[quoted text clipped - 45 lines]
> Thanks,
> Dave

Follow up... for the record, manually adding a key pair to the
dictionary in the onInsertingEvent DOES work, but I still think its
clumsy... and would like to know if there is a better way?

Thanks again,
Dave

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.