protected void BtnEdit_Click(object sender, EventArgs e) { string commentID = string.Empty; for (int i = 0; i <= GridView1.Rows.Count - 1; i++) { CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBox"); if (cbox.Checked == true) { commentID = GridView1.DataKeys[i].Value.ToString(); break; } } MissedPetComment petcomment = new MissedPetComment(); CTMissedPetInfoComment comment = new CTMissedPetInfoComment(); comment = petcomment.GetMissPetCommentByCommentID(commentID); tbMissID.Text = comment.MissID; tbCommentID.Text = comment.CommentID; tbCommentTime.Text = comment.CommentTime; tbContent.Text = comment.CommentContent; tbIP.Text = comment.IP; tbUserID.Text = comment.UserID; cbIsVisible.Checked = comment.IsVisible; }