Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9084553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T21:01:37+00:00 2026-06-16T21:01:37+00:00

I received the error: Unable to cast object of type ‘System.Data.DataRow’ to type ‘System.Data.DataRowView’.

  • 0

I received the error:

Unable to cast object of type ‘System.Data.DataRow’ to type ‘System.Data.DataRowView’.

    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 >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);
            }
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T21:01:38+00:00Added an answer on June 16, 2026 at 9:01 pm

    Error is coming in following line due to data type mismatch.

    foreach (DataRowView dr in dscrntProd.Rows) // as dscrntProd  is DataTable
    

    It should be like

    foreach (DataRow dr in dscrntProd.Rows)
    {
      addToOrder(GetOrderDataRowViewFromDataFow(dr));
    }  
    

    You need to write GetOrderDataRowViewFromDataRow.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

With the following code, I receive an unable to implicitly cast compilation error on
Error Unable to start activity ComponentInfo: java.lang.IllegalStateException: System services not available to Activities before
I'm getting No Data Received. Unable to load the webpage because the server sent
When I tried to open my SharePoint extended site, I received error 500. The
I received this error on following code.Is this + sign is not available in
I received the error while trying to display some variable like so: echo id
String s = new String({'h','e','l','l','o'}); I received the error: 1 Invalid expression term '{'
Received a strange error when using secure websockets in Safari with Webbit server. Error
I received the following error when I tried to run a C# WinForms application
Within my ajax call if an error is received I have an alert :

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.