Request.QueryString is always null

Posted on 2007-10-08
Last Modified: 2008-01-09
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:
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
Question by:arthrex
    LVL 26

    Expert Comment

    by:Anurag Thakur
    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
    LVL 29

    Expert Comment

    by:Gautham Janardhan
    u are sure that there is no space after  'pid' like

    ?pid ="2";

    Author Comment

    Thanks for your answers!
    There are no spaces.
    What config settings do you mean ragi0017?
    LVL 39

    Expert Comment

    by:Pratima Pharande
    Just try with


    is it working ?

    Author Comment

    Request["pid"]  is also null

    Author Comment

    In DebugMode the value for Request QueryString is {}
    LVL 39

    Expert Comment

    by:Pratima Pharande
    Is this is same problem for other pages also in project ?/

    Author Comment

    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)">
                    <asp:QueryStringParameter DefaultValue="1" Name="ProjectID" QueryStringField="pid"
                        Type="Int32" />
    LVL 39

    Accepted Solution

    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)"

    Author Comment

    thanks it thanks

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
    A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    This video discusses moving either the default database or any database to a new volume.

    760 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

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now