Request.QueryString is always null

Hi Experts,

I'm trying to receive a value out of a query string.
In all my other sites it's working fine, but in one site the whole request.querystring is always null.
What might be the reason?
The query in the browser looks like this:
http://server/folder/site.aspx?pid=2
and the page_load:
       protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["pid"] != null)
               int pid = Convert.ToInt32(Request.Params["pid"]));
       }

Please help! Thanks! Regards
arthrexAsked:
Who is Participating?
 
Pratima PharandeConnect With a Mentor Commented:
SelectCommand="SELECT col1, col2 FROM [table] WHERE ([ProjectID] = @ProjectID)"


you need to modify the query , query needs to return pid fild in prder to set it

SelectCommand="SELECT col1 as pid, col2 FROM [table] WHERE ([ProjectID] = @ProjectID)"
0
 
Anurag ThakurTechnical ManagerCommented:
to be very frank i dont see anything wrong in what you are trying to do.
Please check if any configuration is worng. Thats what might go wrong. Code wise its seems ok
0
 
Gautham JanardhanCommented:
u are sure that there is no space after  'pid' like

?pid ="2";
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
arthrexAuthor Commented:
Thanks for your answers!
There are no spaces.
What config settings do you mean ragi0017?
Thanks!
0
 
Pratima PharandeCommented:
Just try with

Request["pid"]  

is it working ?
0
 
arthrexAuthor Commented:
unfortunately
Request["pid"]  is also null
0
 
arthrexAuthor Commented:
In DebugMode the value for Request QueryString is {}
0
 
Pratima PharandeCommented:
Is this is same problem for other pages also in project ?/
0
 
arthrexAuthor Commented:
no all other pages are working fine.
maybe it has something to do with the gridview?
the page itself works fine. sending another pid than 1 brings the right result.
just accessing the query in code's not working.

        <asp:SqlDataSource ID="DB" runat="server" ConnectionString="<%$ .... %>"
            SelectCommand="SELECT col1, col2 FROM [table] WHERE ([ProjectID] = @ProjectID)">
            <SelectParameters>
                <asp:QueryStringParameter DefaultValue="1" Name="ProjectID" QueryStringField="pid"
                    Type="Int32" />
0
 
arthrexAuthor Commented:
thanks it thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.