Solved

Difficulty passing QueryString

Posted on 2006-11-06
5
408 Views
Last Modified: 2008-03-06
Hello,

Can someone please give me a bit of assistance here?  For some reason, I cannot pass a querystring to a dropdown box in this manner:

<asp:SqlDataSource ID="SQLConn" runat="server" ConnectionString="<%$ ConnectionStrings:WebConn %>" SelectCommand="SELECT PO FROM tblPO WHERE PO='<% =Request.Querystring.Tostring() %>'">
        </asp:SqlDataSource>
        &nbsp;
     
        <asp:DropDownList ID="DropDownList" runat="server" DataSourceID="SQLConn" DataTextField="PO" DataValueField="PO">
        </asp:DropDownList></td>

I can see the querystring if I do this:

<%  Response.Write(Request.QueryString)%>

I can also declare it and print it:
<%  Dim X As String = Request.QueryString.ToString()
    Response.Write(X)
%>

I just cannot pass it to the select command.

Thanks in advance for your help.
0
Comment
Question by:iptrader
  • 3
  • 2
5 Comments
 
LVL 16

Accepted Solution

by:
muzzy2003 earned 250 total points
ID: 17881930
You need to use a named querystring parameter, say "?po=xxx" and a QueryStringParameter:

<asp:SqlDataSource ID="SQLConn" runat="server" ConnectionString="<%$ ConnectionStrings:WebConn %>" SelectCommand="SELECT PO FROM tblPO WHERE PO=@PO">
                            <SelectParameters>
                                <asp:QueryStringParameter Name="PO" QueryStringField="po" Type="Int32" />
                            </SelectParameters>
</asp:SqlDataSource>

(Obviously replace the Type with whatever you need.)
0
 

Author Comment

by:iptrader
ID: 17882220
"You need to use a named querystring parameter, say "?po=xxx" and a QueryStringParameter:"

muzzy2003, can you please expand on this a bit?

Thanks
0
 
LVL 16

Expert Comment

by:muzzy2003
ID: 17882256
0
 

Author Comment

by:iptrader
ID: 17882865
Thanks for your help!
0
 
LVL 16

Expert Comment

by:muzzy2003
ID: 17882955
No problem
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now