protected void btnSubmitNotes_Click(object sender, EventArgs e) { if (IsProjectNotesValid(btnSubmitNotes.Text.ToLower())) { string URL = txtURL.Text; if (!URL.Contains("http")) { URL = "http://" + URL; } if (btnSubmitNotes.Text.ToLower() == "submit") { EntityNotesData.AddEntityNotes(DataUtils.GetInt(EntityId), DataUtils.GetInt(ddlCategory.SelectedValue.ToString()), Context.User.Identity.GetUserName().Trim(), txtNotes.Text, URL); } else { EntityNotesData.UpdateEntityNotes(DataUtils.GetInt(hfEntityNotesId.Value), DataUtils.GetInt(ddlCategory.SelectedValue.ToString()), txtNotes.Text, URL, cbActive.Checked); hfEntityNotesId.Value = ""; gvProjectNotes.EditIndex = -1; btnSubmitNotes.Text = "Submit"; } ddlCategory.SelectedIndex = -1; txtNotes.Text = ""; txtURL.Text = ""; BindProjectNotesGrid(); } }
private void BindProjectNotesGrid() { DataTable dt = EntityNotesData.GetEntityNotesList(DataUtils.GetInt(EntityId), cbActiveOnly.Checked); if (dt.Rows.Count > 0) { dvProjectNotesGrid.Visible = true; gvProjectNotes.DataSource = dt; gvProjectNotes.DataBind(); } else { dvProjectNotesGrid.Visible = false; gvProjectNotes.DataSource = null; gvProjectNotes.DataBind(); } }
protected void gvProjectNotes_RowDataBound(object sender, GridViewRowEventArgs e) { try { if (e.Row.RowType == DataControlRowType.DataRow) { Label lblUserName = (Label)e.Row.FindControl("lbluserName"); if (lblUserName.Text.ToLower().Trim() != Context.User.Identity.GetUserName().Trim()) { LinkButton lnkEdit = (LinkButton)e.Row.FindControl("lnkEdit"); lnkEdit.Visible = false; } } if ((e.Row.RowState & DataControlRowState.Edit) == DataControlRowState.Edit) { CommonHelper.GridViewSetFocus(e.Row); //Checking whether the Row is Data Row if (e.Row.RowType == DataControlRowType.DataRow) { //e.Row.Cells[5].Controls[0].Visible = false; btnSubmitNotes.Text = "Update"; Label lblEntityNotesID = e.Row.FindControl("lblEntityNotesID") as Label; DataRow dr = EntityNotesData.GetProjectNotesById(DataUtils.GetInt(lblEntityNotesID.Text)); hfEntityNotesId.Value = lblEntityNotesID.Text; txtNotes.Text = dr["Notes"].ToString(); txtURL.Text = dr["URL"].ToString(); ddlCategory.SelectedValue = dr["LKProjCategory"].ToString(); cbActive.Checked = DataUtils.GetBool(dr["RowIsActive"].ToString()); } } } catch (Exception ex) { LogError(Pagename, "gvProjectNotes_RowDataBound", "", ex.Message); } }