Set QueryStringField from Code

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
 
J

Jonathan Wood

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

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

Jonathan
 

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,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top