Set QueryStringField from Code

  • Thread starter Thread starter Jonathan Wood
  • Start date Start date
J

Jonathan Wood

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
 
After playing with this, I'm thinking this is the answer:

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

Jonathan
 
Back
Top