Set QueryStringField from Code

Discussion in 'ASP .Net' started by Jonathan Wood, Dec 10, 2008.

  1. I'd like to program my ObjectDataSource object from my page's Load event.

    Initially, the object is defined like this:

    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
    SelectMethod="Select" TypeName="SoftCircuits.Sounds" EnablePaging="True"
    StartRowIndexParameterName="startRow" MaximumRowsParameterName="maxRows"
    SelectCountMethod="SelectCount" >
    <SelectParameters>
    <asp:QueryStringParameter DefaultValue="0" Name="categoryId"
    QueryStringField="cat" Type="Int32" />
    </SelectParameters>
    </asp:ObjectDataSource>

    I want to write code to change the parameter to be a different type and
    based on a different querystring. I started with this:

    Parameter parm = ObjectDataSource1.SelectParameters[0];
    parm.Name = "find";
    parm.Type = TypeCode.String;

    But Parameter has no property that specify which query string it uses, or
    even if it uses a query string. How can I change this programatically?

    Thanks.

    Jonathan
     
    Jonathan Wood, Dec 10, 2008
    #1
    1. Advertising

  2. After playing with this, I'm thinking this is the answer:

    QueryStringParameter parm =
    (QueryStringParameter)ObjectDataSource1.SelectParameters[0];

    Jonathan

    "Jonathan Wood" <> wrote in message
    news:...
    > I'd like to program my ObjectDataSource object from my page's Load event.
    >
    > Initially, the object is defined like this:
    >
    > <asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
    > SelectMethod="Select" TypeName="SoftCircuits.Sounds" EnablePaging="True"
    > StartRowIndexParameterName="startRow" MaximumRowsParameterName="maxRows"
    > SelectCountMethod="SelectCount" >
    > <SelectParameters>
    > <asp:QueryStringParameter DefaultValue="0" Name="categoryId"
    > QueryStringField="cat" Type="Int32" />
    > </SelectParameters>
    > </asp:ObjectDataSource>
    >
    > I want to write code to change the parameter to be a different type and
    > based on a different querystring. I started with this:
    >
    > Parameter parm = ObjectDataSource1.SelectParameters[0];
    > parm.Name = "find";
    > parm.Type = TypeCode.String;
    >
    > But Parameter has no property that specify which query string it uses, or
    > even if it uses a query string. How can I change this programatically?
    >
    > Thanks.
    >
    > Jonathan
    >
     
    Jonathan Wood, Dec 10, 2008
    #2
    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. Alan Silver
    Replies:
    0
    Views:
    549
    Alan Silver
    Dec 21, 2005
  2. Manav
    Replies:
    0
    Views:
    800
    Manav
    Oct 15, 2003
  3. Harald Kirsch
    Replies:
    4
    Views:
    2,871
    Harald Kirsch
    Aug 31, 2004
  4. Replies:
    9
    Views:
    434
    Paul McGuire
    Sep 16, 2006
  5. David Mathog
    Replies:
    9
    Views:
    597
    Ian Collins
    May 26, 2012
Loading...

Share This Page