protected void checkall_CheckedChanged(object sender, EventArgs e) { CheckBox checkall = (CheckBox)sender; foreach (GridViewRow gr in gvSearch.Rows) { CheckBox checkselect = (CheckBox)gr.FindControl("chkSelectGroupR"); var lblPaymentNo = (Label)gr.FindControl("lblPaymentNo"); var lblHeadRequestNo = (Label)gr.FindControl("lblHeadRequestNo"); var lblUPLOAD_GROUP_NO = (Label)gr.FindControl("lblUPLOAD_GROUP_NO"); var lblSEQ_NO = (Label)gr.FindControl("lblSEQ_NO"); if (checkall.Checked) { if (!checkselect.Checked) { ListLicense.Add(new DTO.GenLicense { HEAD_REQUEST_NO = lblHeadRequestNo.Text, PAYMENT_NO = lblPaymentNo.Text, USER_ID = base.UserId, UPLOAD_GROUP_NO = lblUPLOAD_GROUP_NO.Text, SEQ_NO = lblSEQ_NO.Text, }); checkselect.Checked = true; } } else { var pament = ListLicense.FirstOrDefault(x => x.UPLOAD_GROUP_NO == lblUPLOAD_GROUP_NO.Text && x.SEQ_NO == lblSEQ_NO.Text); ListLicense.Remove(pament); checkselect.Checked = false; } } }
protected void chkSelectGroupR_CheckedChanged(object sender, EventArgs e) { CheckBox checkselect = (CheckBox)sender; GridViewRow gr = (GridViewRow)checkselect.Parent.Parent; var lblPaymentNo = (Label)gr.FindControl("lblPaymentNo"); var lblHeadRequestNo = (Label)gr.FindControl("lblHeadRequestNo"); var lblUPLOAD_GROUP_NO = (Label)gr.FindControl("lblUPLOAD_GROUP_NO"); var lblSEQ_NO = (Label)gr.FindControl("lblSEQ_NO"); if (checkselect.Checked) { var ChkGroupNo = ListLicense.FirstOrDefault(x => x.UPLOAD_GROUP_NO == lblUPLOAD_GROUP_NO.Text && x.SEQ_NO == lblSEQ_NO.Text); if (ChkGroupNo == null) { this.ListLicense.Add(new DTO.GenLicense { HEAD_REQUEST_NO = lblHeadRequestNo.Text, PAYMENT_NO = lblPaymentNo.Text, USER_ID = base.UserId, UPLOAD_GROUP_NO = lblUPLOAD_GROUP_NO.Text, SEQ_NO = lblSEQ_NO.Text, }); } } else { var pament = ListLicense.FirstOrDefault(x => x.UPLOAD_GROUP_NO == lblUPLOAD_GROUP_NO.Text && x.SEQ_NO == lblSEQ_NO.Text); ((CheckBox)((GridView)gr.Parent.Parent).HeaderRow.FindControl("Checkall")).Checked = false; ListLicense.Remove(pament); //((CheckBox)((GridView)gr.Parent.Parent).HeaderRow.FindControl("checkall")).Checked = false; //ListLicense.Remove(lblGroupRequestNo.Text); } }