protected void GridViewBU_RowDataBound(object sender, GridViewRowEventArgs e) { // GridViewDetails.Visible = true; GridViewBU.Visible = true; Grant_DataObject obj = new Grant_DataObject(); string Uid = null; string username = DropDownList1.SelectedValue; Uid = obj.selectUIdDropdown(username); con.Open(); SqlCommand cmd = new SqlCommand("select distinct Institute_Id from User_Institution_Map where User_Id=@ID", con); cmd.Parameters.AddWithValue("@ID", username); SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { string busunit = (string)rdr["Institute_Id".Trim()]; if (e.Row.RowType == DataControlRowType.DataRow) { var checkid = e.Row.FindControl("CheckBoxMark1") as CheckBox; string bu = (DataBinder.Eval(e.Row.DataItem, "Institute_Id".Trim()).ToString()); if (bu.Trim() == busunit.Trim()) { checkid.Checked = true; } } } con.Close(); }
protected void Butsave_Click(object sender, EventArgs e) { if (!Page.IsValid) { return; } Grant_DataObject obj = new Grant_DataObject(); string Uid = null; string username = DropDownList1.SelectedValue; Uid = obj.selectUIdDropdown(username); string userid = Session["UserId"].ToString(); ArrayList userBU = new ArrayList(); int res = 1; for (int i = 0; i <= GridViewBU.Rows.Count - 1; i++) { string ID = GridViewBU.Rows[i].Cells[1].Text.Trim(); GridViewRow row = GridViewBU.Rows[i]; CheckBox ck = (CheckBox)row.FindControl("CheckBoxMark1"); if (ck.Checked == true) { userBU.Add(ID); } } /* Invoke Business Layer to insert data */ Business B = new Business(); res = B.updateAdditionalBU(userBU, username); if (res == 1) { ClientScript.RegisterStartupScript(Page.GetType(), "validation1", "<script language='javascript'>alert('USER UPDATED')</script>"); log.Info("User Updated successfully UserID:" + Uid); } }