By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,408 Members | 1,840 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,408 IT Pros & Developers. It's quick & easy.

Request .querystring problem

P: n/a
Hi have have some link like thi
http://x.com/Shoppingcart.aspx?pn=ps...e&action=updat
now I want to request the dat
I use this code in as
<%For Each strPartNo In Request.QueryString("pn"
lngQty = Request.QueryString("qty_" & strPartNo
strPartNo = LCase(strPartNo
Response.Write("strPartNo"& strPartNo& lngQty
Next
%
but in .Net when I try to use it it say it have error do you have any ide

foreach (string strPartNo in Request.QueryString["pn"])

int lngQty = Request.QueryString["qty_" + strPartNo]
Response.Write(strPartNo+Request.QueryString["pn"]+"<br>")
}
Nov 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Not knowing he error, it's a little hard to tell. Right off the bat though,
it could be because you can't just set a variable equal to the querystring.
When you reference Request.QueryString["qty_" + strPartNo], how will it know
what to do with the value. In VBScript, all the variables are of type
variant. This means they change their behavior depending upon their context.
In strongly typed languages, such as C#, you have to implicitely cast the
value. You can try to do it in two ways:

one way is:
int lngQty = (int)Request.QueryString["qty_" + strPartNo];
which attempts to implicitely cast it or:

int lngQty = Convert.ToInt32(Request.QueryString["qty_" +
strPartNo].ToString());
passes it through the convert function to change the string value into a
32-bit int.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage

"mahsa" <an*******@discussions.microsoft.com> wrote in message
news:B5**********************************@microsof t.com...
Hi have have some link like this
http://x.com/Shoppingcart.aspx?pn=ps...&action=update now I want to request the data
I use this code in asp
<%For Each strPartNo In Request.QueryString("pn")
lngQty = Request.QueryString("qty_" & strPartNo)
strPartNo = LCase(strPartNo)
Response.Write("strPartNo"& strPartNo& lngQty)
Next
%>
but in .Net when I try to use it it say it have error do you have any idea
foreach (string strPartNo in Request.QueryString["pn"])
{
int lngQty = Request.QueryString["qty_" + strPartNo];
Response.Write(strPartNo+Request.QueryString["pn"]+"<br>");
}

Nov 18 '05 #2

P: n/a
hi tanck you actualy my problem is with this par
foreach (string strPartNo in Request.QueryString["pn"]
this part give error if i write foreach (string strPartNo in Request.QueryString) it works but i just want pn not all the values

Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.