Looping arraylist and display in datagridView , C# Winform
I have some productID
as string with comma let say "10,11,12"
in variable products
and I split them
string[] productlist = products.Split(',');
But when I want to display name of those products in datagridview, I only get the last one. Not all three products.
Here is my code:
foreach (var item in productlist)
{
int Pid = Convert.ToInt32(item);
var pro = (from u in db.Product
where u.ProductId == Pid
select new
{
Productname = u.ProductNamn
}).Tolist();
dgvProduct.DataSource = pro;
}
How should my code look like? I know there is something wrong when I looping, but I don't know how to fix it.
I would very appreciate your help guys and thank you in advance
from Recent Questions - Stack Overflow https://ift.tt/39AGGU7
https://ift.tt/eA8V8J
Comments
Post a Comment