Foreach cycle

foreach (DataGridItem dgi in dgResult.Items )
{
CheckBox cbox = (CheckBox)dgi.FindControl("chkselect");
if (cbox.Checked)
{

DataTable dt = new DataTable();
DataRow dr;
dt.TableName = "adjSN";
dt.Columns.Add("SN", typeof(string));
dt.Columns.Add("DealerID", typeof(string));
for (int i = 0; i <myData.Tables[0].Rows.Count; i++)
{
dr = dt.NewRow();
dr["SN"] = myData.Tables[0].Rows[i]["SN"].ToString();
dr["DealerID"] = myData.Tables[0].Rows[i]["DealerID"].ToString();
dt.Rows.Add(dr);
}
int num = SNManage_lib.AdjustSN.AdjBySN(this.portaluser.Id, AcerACCN.Portal.Utility.XMLTools.DataTable2Xml(dt));
if (num > 0)
{
JScript.Alert("Submitted to the success");

}
else
{
JScript.Alert("Failed to commit");
BindGrid();
}
}
else
{
JScript.Alert("You have not selected dataļ¼");
BindGrid();
}
}

Trouble you to help have a look this code, execute to foreach directly out of the loop, my list is a data

Started by Vincent at November 26, 2016 - 9:14 PM

Debug, what is your DGI?

Posted by Catherine at December 06, 2016 - 10:03 PM

I had to debug, not once implemented, directly out of the loop.

Posted by Vincent at December 09, 2016 - 10:18 PM

What version of DataGrid.

Posted by Abner at December 24, 2016 - 11:06 PM

This kind of problem, or specific debug only know.. Single meat glance, look a little eyes shining. .
Have a look the number of dgResult.Items, and whether there is abnormal.

Posted by Sabrina at January 08, 2017 - 11:16 PM