GridView

StringBuilder sbLogID = new StringBuilder();
foreach (GridViewRow row in gvLog.Rows)
{
      CheckBox chk = row.FindControl("chkItem") as CheckBox;

       if (chk != null && chk.Checked)
       {
             sbLogID.AppendFormat("{0}|", gvLog.DataKeys[row.RowIndex].Value);
       }
}

if (sbLogID.Length > 1)
{
      sbLogID.Remove(sbLogID.Length - 1, 1);
}

原文地址:https://www.cnblogs.com/libingql/p/1789944.html