Solved

Difficulty passing QueryString

Posted on 2006-11-06
5
443 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

726 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