title: Request.QueryString cannot be found but has values
body: <p>I have a page which is below.</p>
  
  <p><a href="https://i.stack.imgur.com/ODKHi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ODKHi.png" alt="HERE IS IMAGE"></a></p>
  
  <p>I have 2 GridView</p>
  
  <p>Labes &amp; TextBoxes</p>
  
  <p>And A Button</p>
  
  <p>When the <strong>RECEIVED</strong> <strong>btn</strong> is <strong>CLICKED</strong>, 
  It saves in the correct database and other commands i set into.</p>
  
  <p>But my <strong>Command if (Request.QueryString["Status"] == "Received")</strong>,</p>
  
  <p><strong>DOES NOT WORK</strong> and that the <strong>"Status"</strong> said to be/found out <strong><em>null</em></strong></p>
  
  <p>But it has values even in my database</p>
  
  <p>and was updated by the command i set to.</p>
  
  <p><a href="https://i.stack.imgur.com/DCkoq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DCkoq.png" alt="HERE"></a></p>
  
  <p><strong>HERE IS ASP.NET CODES:</strong></p>
  
  <pre><code> &lt;div class="col-lg-12"&gt;
        &lt;center&gt;
          &lt;br /&gt;
          &lt;i class="fa fa-user" style="font-size: xx-large;"&gt; &amp;nbsp; Receiving&lt;/i&gt; &lt;br /&gt;&lt;br /&gt;
           &lt;i&gt;&amp;nbsp;See below the PO Details &amp; Status&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;
  
           &lt;div id="error2" runat="server" class="alert alert-danger" visible="false"&gt;
              This Purchase Order had already been received.
          &lt;/div&gt;
  
           &lt;asp:Label runat="server" ID="Label1" Font-Bold="True"&gt; PR By:&lt;/asp:Label&gt;&amp;nbsp; 
           &lt;asp:Label runat="server" ID="txtPRBy"&gt;&lt;/asp:Label&gt;&amp;nbsp;
           &lt;asp:Label runat="server" ID="Label2" Font-Bold="True"&gt; Approved By:&lt;/asp:Label&gt;&amp;nbsp; 
           &lt;asp:Label runat="server" ID="txtOrderBy"&gt;&lt;/asp:Label&gt;&amp;nbsp;
           &lt;asp:Label runat="server" ID="Label3" Font-Bold="True"&gt; PO Date:&lt;/asp:Label&gt;&amp;nbsp; 
           &lt;asp:Label runat="server" ID="txtPODate"&gt;&lt;/asp:Label&gt;&amp;nbsp;
           &lt;asp:Label runat="server" ID="Label4" Font-Bold="True"&gt; Final Delivery Date:&lt;/asp:Label&gt;&amp;nbsp; 
           &lt;asp:Label runat="server" ID="txtFinalDelDate"&gt;&lt;/asp:Label&gt;
           &lt;br /&gt;
           &lt;br /&gt;
            &lt;asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
                DataSourceID="ReceivingPO"&gt;
                &lt;Columns&gt;
                    &lt;asp:BoundField DataField="POID" HeaderText="POID" SortExpression="POID" /&gt;
                    &lt;asp:BoundField DataField="ProductID" HeaderText="ProductID" 
                        SortExpression="ProductID" /&gt;
                    &lt;asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" /&gt;
                    &lt;asp:BoundField DataField="Price" HeaderText="Price" SortExpression="Price" /&gt;
                    &lt;asp:BoundField DataField="Quantity" HeaderText="Quantity" 
                        SortExpression="Quantity" /&gt;
                    &lt;asp:BoundField DataField="Amount" HeaderText="Amount" 
                        SortExpression="Amount" /&gt;
                    &lt;asp:BoundField DataField="Status" HeaderText="Status" 
                        SortExpression="Status" /&gt;
                &lt;/Columns&gt;
            &lt;/asp:GridView&gt;
  
            &lt;asp:SqlDataSource ID="ReceivingPO" runat="server" 
                ConnectionString="&lt;%$ ConnectionStrings:MyOwnMeatshopConnectionString %&gt;" 
                SelectCommand="SELECT PODetails.POID, PODetails.ProductID, PODetails.Name, PODetails.Price, PODetails.Quantity, PODetails.Amount, PO.Status FROM PODetails INNER JOIN PO ON PODetails.POID = PO.POID WHERE (PODetails.POID = @POID)"&gt;
                &lt;SelectParameters&gt;
                    &lt;asp:QueryStringParameter Name="POID" QueryStringField="ID" Type="Int32" /&gt;
                &lt;/SelectParameters&gt;
            &lt;/asp:SqlDataSource&gt;
  
         &lt;/center&gt;
  
         &lt;asp:Button ID="btnApprove" runat="server" class="btn btn-success" text="Receive" 
                onclick="btnApprove_Click" /&gt;
  
              &lt;center&gt;&lt;i&gt;&amp;nbsp;See below the PO Receiving Details&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;
  
  
              &lt;asp:Label runat="server" ID="Label5" Font-Bold="True"&gt;Received By:&lt;/asp:Label&gt;&amp;nbsp;
              &lt;asp:Label runat="server" ID="txtFN"&gt;&lt;/asp:Label&gt;
              &lt;asp:Label runat="server" ID="txtLN"&gt;&lt;/asp:Label&gt;&amp;nbsp;
              &lt;asp:Label runat="server" ID="Label6" Font-Bold="True"&gt; Remarks:&lt;/asp:Label&gt;&amp;nbsp;
              &lt;asp:TextBox runat="server" ID="txtRemarks" Width="300px"&gt;&lt;/asp:TextBox&gt;&amp;nbsp;
              &lt;br /&gt;
              &lt;br /&gt;
                  &lt;asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False"
                      DataSourceID="received" DataKeyNames="ReceivingID" &gt;
                      &lt;Columns&gt;
                          &lt;asp:BoundField DataField="ReceivingID" HeaderText="ReceivingID" 
                              SortExpression="ReceivingID" InsertVisible="False" ReadOnly="True" /&gt;
                          &lt;asp:BoundField DataField="POID" HeaderText="POID" SortExpression="POID" /&gt;
                          &lt;asp:BoundField DataField="ReceivedBy" HeaderText="ReceivedBy" 
                              SortExpression="ReceivedBy" /&gt;
                          &lt;asp:BoundField DataField="DateReceived" HeaderText="DateReceived" 
                              SortExpression="DateReceived" /&gt;
                          &lt;asp:BoundField DataField="Status" HeaderText="Status" 
                              SortExpression="Status" /&gt;
                      &lt;/Columns&gt;
                  &lt;/asp:GridView&gt;
  
                  &lt;asp:SqlDataSource ID="received" runat="server" 
                      ConnectionString="&lt;%$ ConnectionStrings:MyOwnMeatshopConnectionString %&gt;" 
                      SelectCommand="SELECT Receiving.ReceivingID, Receiving.POID, Receiving.ReceivedBy, Receiving.DateReceived, Receiving.Status FROM Receiving INNER JOIN PO ON Receiving.POID = PO.POID WHERE (Receiving.POID = @POID)"&gt;
                      &lt;SelectParameters&gt;
                          &lt;asp:QueryStringParameter Name="POID" QueryStringField="ID" Type="Int32" /&gt;
                      &lt;/SelectParameters&gt;
                  &lt;/asp:SqlDataSource&gt;
  
              &lt;/center&gt;
            &lt;br /&gt;
            &lt;br /&gt;
         &lt;/div&gt;
  </code></pre>
  
  <p><strong>HERE IS CODE BEHIND (btn Received)</strong></p>
  
  <pre><code>        protected void btnApprove_Click(object sender, EventArgs e)
      {
          con.Open();
          SqlCommand cmd = new SqlCommand();
          cmd.Connection = con;
  
          if (Request.QueryString["Status"] == "Received")
          {
              error2.Visible = true;
          }
  
          else
          {
                  foreach (GridViewRow row in GridView1.Rows)
                  {
  
  
                      if (row.RowType == DataControlRowType.DataRow)
                      {
  
  
                          string ProductID = GridView1.Rows[row.RowIndex].Cells[1].Text;
                          int Quantity = int.Parse(GridView1.Rows[row.RowIndex].Cells[4].Text);
  
  
                          cmd.CommandText = "INSERT INTO Receiving VALUES (@POID, @RequestedBy, " +
                                  "@OrderBy, @PODate, @FinalDeliveryDate, @DateReceived, @ReceivedBy, @Status, @Remarks)";
                          cmd.Parameters.AddWithValue("@POID", Request.QueryString["ID"].ToString());
                          cmd.Parameters.AddWithValue("@RequestedBy", txtPRBy.Text);
                          cmd.Parameters.AddWithValue("@OrderBy", txtOrderBy.Text);
                          cmd.Parameters.AddWithValue("@PODate", txtPODate.Text);
                          cmd.Parameters.AddWithValue("@FinalDeliveryDate", txtFinalDelDate.Text);
                          cmd.Parameters.AddWithValue("@DateReceived", DateTime.Now);
                          cmd.Parameters.AddWithValue("@ReceivedBy", txtLN.Text + txtFN.Text);
                          cmd.Parameters.AddWithValue("@Status", "Received");
                          cmd.Parameters.AddWithValue("@Remarks", txtRemarks.Text);
                          cmd.ExecuteNonQuery();
  
                          cmd.CommandText = "UPDATE PO SET Status=@Status WHERE POID=@POID";
                          cmd.ExecuteNonQuery();
  
                          cmd.CommandText = "UPDATE Products SET Available+=@Quantity WHERE ProductID=@ProductID";
                          cmd.Parameters.Add("@ProductID", SqlDbType.VarChar).Value = ProductID.ToString();
                          cmd.Parameters.AddWithValue("@Quantity", Quantity);
                          cmd.ExecuteNonQuery();
  
                          GridView1.DataBind();
                          con.Close();
                      }
  
  
                  }
  
  
  
          }
      }
  </code></pre>
  
  <p>in my other page it worked. But here no.</p>
  
  <p>Help Guys thank you in advance!</p>
  
  <p>i just don't know why it happens</p>
  
  <p>Also i set codes in the page load </p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
          {
  if (Request.QueryString["ID"] != null)
              {
                  int POID = 0;
                  bool validpurch = int.TryParse(Request.QueryString["ID"].ToString(), out POID);
  
                  if (validpurch)
                  {
                      if (!IsPostBack)
                      {
                          getPO();
                          GetUser();
                      }
                  }
                  else
                      Response.Redirect("Default.aspx");
              }
              else
                  Response.Redirect("Default.aspx");
          }
  </code></pre>