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

Discussion in 'ASP .Net Web Controls' started by PugOne, Aug 5, 2005.

  1. PugOne

    PugOne Guest

    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
    PugOne, Aug 5, 2005
    #1
    1. Advertising

  2. PugOne

    Brock Allen Guest

    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);
    }


    -Brock
    DevelopMentor
    http://staff.develop.com/ballen



    > 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
    >
    Brock Allen, Aug 7, 2005
    #2
    1. Advertising

  3. PugOne

    PugOne Guest

    Re: Selecting Event in ASP.NET 2.0 fires too late to set parameter

    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

    "Brock Allen" wrote:

    > 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);
    > }
    >
    >
    > -Brock
    > DevelopMentor
    > http://staff.develop.com/ballen
    >
    >
    >
    > > 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
    > >

    >
    >
    >
    >
    PugOne, Aug 8, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steve M
    Replies:
    5
    Views:
    552
    Yan-Hong Huang[MSFT]
    Jul 31, 2003
  2. inquiredMind
    Replies:
    13
    Views:
    586
  3. Jason
    Replies:
    0
    Views:
    624
    Jason
    Nov 12, 2006
  4. QuantumG
    Replies:
    96
    Views:
    1,541
    Rob Thorpe
    Oct 26, 2004
  5. Replies:
    3
    Views:
    982
Loading...

Share This Page