Setting ObjectDataSource Select Parameters at RunTime

I had a need to set some of the ObjectDataSource parameters for my select statement at runtime. Sometimes the parameters are set from a cookie, other times from a querystring and sometimes from a form field.

To set the parameters at runtime, you need to implement the Selecting Event for the ObjectDataSource and then use the InputParameter for the ObjectDataSourceSelectingEventArgs to set the value.

Example:

protected void ObjectDataSource1_Selecting(object sender,ObjectDataSourceSelectingEventArgs e)
{
e.InputParameters["MyParameterName"] = ParameterValue;
}


Related posts

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

November 21. 2008 06:02 PM