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);
}

你可能感兴趣的:(GridView)