Request .querystring problem

G

Guest

Hi have have some link like thi
http://x.com/Shoppingcart.aspx?pn=p...04000=1&sku=PS50210&cat=laminate&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>")
}
 
M

Mark Fitzpatrick

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top