Solved

Difficulty passing QueryString

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Connection String 16 57
SQL Login 17 50
Why does my excel data start at B1 instead of A1. 9 83
ASP.net Fit 3 divs on screen side by side 3 26
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

772 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