views:

56

answers:

1

This should be pretty straight forward but I can't seem to get my newbie mind around it. I have a ASP.net page that needs to create a new database entry based on user input from a web form.

One control in the form is a DropDownBox that is databound to a LinqDataSource whose context is a LinqToSQL data class. The table it is bound to is the default ASP.net aspnet_Users table.

So I have this drop down list that displays all of the users stored in that table. I have a table called Events that has a foreign key relationship with aspnet_Users (each Event has a aspnet_User) and so I need that aspnet_Users UserId value to create a new Event object. How do I get this value from the selected item in the drop-down box? I'm sure this is much simpler than I'm making it.

+1  A: 

Can you post some code of how you're binding this?

If it is bound to the user properly, you should be able to do the following.

UserClass user = MyDropDown.SelectedValue as UserClass;

Just substitute the actual class name for the user and the proper name for the dropdown.

Ray Booysen