Selecting Event in ASP.NET 2.0 fires too late to set parameters.

P

PugOne

It appears that in Beta 2 of ASP.NET 2.0 the Selecting event is too late to
set parameters on the datasource. Apparently the command has already been
created. This is not consistent with the documentation. Is this a bug that
will be fixed or are the documents wrong?

Jim
 
B

Brock Allen

Seems to work for me:

protected void _authorDS_Selecting(object sender, SqlDataSourceSelectingEventArgs
e)
{
System.Data.Common.DbParameter p = e.Command.CreateParameter();
p.ParameterName = "foo";
p.Value = "bar";
e.Command.Parameters.Add(p);
}
 
P

PugOne

Ahh. Just enough clues in your snipit for me to find my mental laps. I was
manipulating the datasources parameter collection. Did not realize that the
command was in the event args. (can't wait for more complete documentation!)
Manipulating parameters on that command object works fine as you stated.
That's good news because it really is the logical place to manipulate
parameters. I like to fine logical events that occur as late as possible to
avoid unwanted side effects.

Thanks for your help!

Jim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top