TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Doudy
NA
11
18.9k
Unable to cast object of type 'System.Data.DataRow' to type
Jan 3 2013 11:28 AM
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
)
{
DataTable
dscrntProd
=
prods
.
SelCrntProd4Sale
(
crntProdID
);
//get data from sql server database for product details(productID, ProductName,ProductPrice)
foreach
(
DataRowView
dr
in
dscrntProd
.
Rows
)
{
addToOrder
(
dr
);
}
}
}
Any help Most Appreciated
Thanks.
Reply
Answers (
1
)
SIMPLE DATA RETRIEVING FROM SQL DB
Moving a linklabel up or down