title: How to get values and update 3 tables ASP.NET
body: <p>I send values to other page when I click edit button:</p>
  <pre><code>protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
      {
          if (e.CommandName == &quot;EditButton&quot;)
          {
              string[] arg = new string[3];
              arg = e.CommandArgument.ToString().Split(';');
              Session[&quot;EmployeeID&quot;] = arg[0];
              Session[&quot;ItemID&quot;] = arg[1];
              Session[&quot;InventoryID&quot;] = arg[2];
              //int index = Convert.ToInt32(e.CommandArgument);
              //GridViewRow row = GridView1.Rows[index];
              Response.Redirect(&quot;~/EditLaptop.aspx?EmployeeID=&quot; + Session[&quot;EmployeeID&quot;].ToString().Trim() + &quot;&amp;ItemID=&quot; + Session[&quot;ItemID&quot;].ToString().Trim()
                  + &quot;&amp;InventoryID&quot; + Session[&quot;InventoryID&quot;].ToString().Trim());
  
  
          }
      }
  </code></pre>
  <p>Get values from first page:</p>
  <pre><code>public partial class EditLaptop : System.Web.UI.Page
      {
      
          string empno;
          string itemid;
          string inventoryid;
      
      
          protected void Page_Load(object sender, EventArgs e)
          {
      
              empno = Request.QueryString[&quot;EmployeeID&quot;].ToString();
              itemid = Request.QueryString[&quot;ItemID&quot;].ToString();
              inventoryid = Request.QueryString[&quot;InventoryID&quot;].ToString();
  </code></pre>
  <p>When I click update button it shows error.</p>
  <pre><code>protected void OnUpdate(object sender, EventArgs e)
  {
      string StrConnString = ConfigurationManager.ConnectionStrings[&quot;BenzConnectionString&quot;].ToString();
      SqlConnection objConn = new SqlConnection(StrConnString);
  
      try
      {
          
          objConn.Open();
          SqlCommand objCmd = new SqlCommand(&quot;UPDATE  Employee SET FirstName =  @sFirstName,&quot; +
              &quot; LastName = @sLastName,&quot; +
              &quot; EMail = @sEMail, &quot; +
              &quot;PhoneNo = @sPhoneNo, &quot; +
              &quot;PositionID = @sPositionID, &quot; +
              &quot;DepartmentID = @sDepartmentID&quot; +
              &quot; WHERE  EmployeeID = @sEmployeeID&quot;, objConn);
  
          objCmd.Parameters.AddWithValue(&quot;@sFirstName&quot;, txtfirstname.Text);
          objCmd.Parameters.AddWithValue(&quot;@sLastName&quot;, txtlastname.Text);
          objCmd.Parameters.AddWithValue(&quot;@sEMail&quot;, txtemail.Text);
          objCmd.Parameters.AddWithValue(&quot;@sPhoneNo&quot;, txtphone.Text);
          objCmd.Parameters.AddWithValue(&quot;@sPositionID&quot;, dpposition.Text);
          objCmd.Parameters.AddWithValue(&quot;@sDepartmentID&quot;, dpcenter.Text);
          objCmd.Parameters.AddWithValue(&quot;@sEmployeeID&quot;, empno);
  
          objCmd.ExecuteNonQuery();
  
          objCmd = new SqlCommand(&quot;UPDATE Item SET Brand = @sBrand, &quot; +
              &quot;Model = @sModel, &quot; +
              &quot;Serial_No = @sSerial_No, &quot; +
              &quot;Macaddress = @sMacaddress, &quot; +
              &quot;ItemTypeID = @sItemTypeID, &quot; +
              &quot;ReceiveDate = @sReceiveDate  &quot; +
              &quot;WHERE ItemID = @sItemID &quot;, objConn);
  
          objCmd.Parameters.AddWithValue(&quot;@sBrand&quot;, txtbrand.Text);
          objCmd.Parameters.AddWithValue(&quot;@sModel&quot;, txtmodel.Text);
          objCmd.Parameters.AddWithValue(&quot;@sSerial_No&quot;, txtserial.Text);
          objCmd.Parameters.AddWithValue(&quot;@sMacaddress&quot;, txtmac.Text);
          objCmd.Parameters.AddWithValue(&quot;@sItemTypeID&quot;, dptype.Text);
          objCmd.Parameters.AddWithValue(&quot;@sReceiveDate&quot;, txtreceiveddate.Text);
          objCmd.Parameters.AddWithValue(&quot;@sItemID&quot;, itemid);
  
  
          objCmd = new SqlCommand(&quot;UPDATE SET InventoryLine SET Transaction_date = @sTransaction_date,&quot; +
              &quot; ReturnDate = @sReturnDate &quot; +
              &quot;WHERE InventoryID = @sInventoryID&quot;, objConn);
          objCmd.Parameters.AddWithValue(&quot;@sReturnDate&quot;, txtreturndate.Text);
          objCmd.Parameters.AddWithValue(&quot;@sTransaction_date&quot;, txtreturndate.Text);
          objCmd.Parameters.AddWithValue(&quot;@sInventoryID&quot;, inventoryid);
          objCmd.ExecuteNonQuery();
      }
      catch (Exception ex)
      {
          Response.Write(&quot;&lt;br/&gt; Error : &quot; + ex.Message);
      }
      finally
      {
          objConn.Close();
      }
  }
  </code></pre>
  <hr />
  <p>There is error message when i click update</p>
  <pre><code>Server Error in '/' Application.
  
  Object reference not set to an instance of an object.
  
  Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
  
  Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
  
  Source Error: 
  
  
  Line 24:         empno = Request.QueryString[&quot;EmployeeID&quot;].ToString();
  Line 25:         itemid = Request.QueryString[&quot;ItemID&quot;].ToString();
  Line 26:         inventoryid = Request.QueryString[&quot;InventoryID&quot;].ToString();
  Line 27: 
  Line 28: 
  </code></pre>