Tuesday, March 13, 2012

Set parameter value

I add a datasource to a page and configure it do insert and update to database table. I can see the select, insert and update commands and correspond parameters in the source file.

Now I need pass the values to the parameters. Most parameters value use form parameters. But there is one parameter value do not exist on the page and need to be set. But HOW?

The following seems the only code I can do which is "ADD" a parameter which already exists.

SqlDataSource1.InsertParameters.Add("UserId", userid)

Is there a simple way just set the value of the parameter?

SqlDataSource1.InsertParameters("UserId").value= userid 'DOES'T WORK

Ying

Is this VB? if it is C# then you could do this:

SqlDataSource1.InsertParameters["UserId"].value= userid;


actually, I meant:

SqlDataSource1.InsertParameters["UserId"].DefaultValue = userid

0 comments:

Post a Comment