title: Unable to cast object of type 'System.Data.DataRow' to type 'System.Data.DataRowView
body: <p>I received the error:</p>
  
  <blockquote>
    <p>Unable to cast object of type 'System.Data.DataRow' to type 'System.Data.DataRowView'.</p>
  </blockquote>
  
  <pre><code>    private void addToOrder(DataRowView drv)
      {
          DataRow dr = orderDataTable.NewRow();
          dr["ProductID"] = drv["ProductID"];
          dr["ProductBarcode"] = drv["ProductBarcode"];
          dr["ProductName"] = drv["ProductName"];
          dr["SalePrice"] = drv["SalePrice"];
          dr["SoldQuantity"] = 1;
          dr["NotEditable"] = false;
          try
          {
              orderDataTable.Rows.Add(dr);
          }
          catch (ConstraintException)
          {
              DataRow dr1 = orderDataTable.Rows.Find(drv["ProductID"]);
              dr1["SoldQuantity"] = Convert.ToInt32(dr1["SoldQuantity"]) + 1;
          }
      }
      private void btnAddToOrder_Click(object sender, RoutedEventArgs e)
      {
          // add to order
          if(txtBarcodeAuto.Text.Length &gt;0)
          {
              //get data from sql server database for product details(productID, ProductName,ProductPrice)
              DataTable dscrntProd = prods.SelCrntProd4Sale(crntProdID);
              foreach (DataRowView dr in dscrntProd.Rows)
              {
                  addToOrder(dr);
              }
          }
      }
  </code></pre>