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. Advertisements

  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. Advertisements

  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. Advertisements

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. Purvi T
    Replies:
    0
    Views:
    1,152
    Purvi T
    Oct 19, 2004
  2. Steve M
    Replies:
    5
    Views:
    810
    Yan-Hong Huang[MSFT]
    Jul 31, 2003
  3. George K
    Replies:
    3
    Views:
    1,947
    John Saunders
    Nov 25, 2003
  4. Jon
    Replies:
    1
    Views:
    12,079
    George Ter-Saakov
    Jan 13, 2004
  5. Hannes
    Replies:
    3
    Views:
    493
    Travis Murray
    Aug 19, 2004
  6. =?Utf-8?B?Um9iIFBlbm5lcg==?=

    Asp.Net click event fires on 2000 but not 2003

    =?Utf-8?B?Um9iIFBlbm5lcg==?=, Oct 13, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    464
    =?Utf-8?B?SGFyaSBOYWly?=
    Oct 18, 2004
  7. Replies:
    3
    Views:
    1,220
  8. George K
    Replies:
    2
    Views:
    274
    Ray at
    Nov 24, 2003
Loading...