About Me

My photo
Northglenn, Colorado, United States
I'm primarily a BI Developer on the Microsoft stack. I do sometimes touch upon other Microsoft stacks ( web development, application development, and sql server development).

Monday, August 27, 2007

How to programatically bind a value to a parameter in a ObjectDataSource

I'm making a guestbook, and one of the values that I'm inserting into the database is the IP address of the user. To get the IP address to bind to the parameter "IP" I added a event that is raised when "Inserting" to the objectdatasource.

From here I just add the value:

protected void ObjectDataSource1_Inserting(object sender, ObjectDataSourceMethodEventArgs e)
e.InputParameters["IP"] = Request.UserHostAddress;

No comments: