?
Solved

Difficulty passing QueryString

Posted on 2006-11-06
5
Medium Priority
?
454 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 16

Accepted Solution

by:
muzzy2003 earned 1000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

771 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