Devendra  Kumar

Devendra Kumar

  • NA
  • 517
  • 244.7k

checkbox checked inside data list c#

Sep 1 2016 1:28 AM
i have a form in which  i will bind out off stock product in data list 
 
and inside data list  have check box
 
i want when which item checked then it convert  into  out of stock to available   product
 
this is work properly but when first item checked then it convert   into out of stock to available product but facing error like:
Collection was modified; enumeration operation may not execute.  
 
and my code is like:  on check box checkedchande
 
foreach (DataListItem item in divProducts.Items)
{
Label ProductId = (Label)item.FindControl("label_product");
CheckBox chkbox = (CheckBox)item.FindControl("chkbox");
if (chkbox.Checked)
{
objAdmin.OperationName = "update_avail";
objAdmin.ProductId = Convert.ToInt16(ProductId.Text);
objAdmin.Pro_avail = "Available";
objAdmin.Quantity = 30;
DataSet ds = objAdmin.selectoutofstock();
BindGrid();
}
}
 

Answers (2)