protected void DeleteImage_Click(object sender, EventArgs e) { DnnImageButton deleteImage = (DnnImageButton)sender; int surveyID = Convert.ToInt32(deleteImage.CommandArgument); int[] surveyIDs = (from p in Request.Form["SurveyID"].Split(',') select int.Parse(p)).ToArray(); int viewOrder = 1; List <SurveysInfo> surveys = Surveys; SurveysInfo survey; foreach (int sID in surveyIDs) { survey = surveys.Find(x => x.SurveyID == sID); if (sID == surveyID) { surveys.Remove(survey); } else { survey.ViewOrder = viewOrder; survey.LastModifiedByUserID = UserId; viewOrder++; } } Surveys = surveys; QuestionsGrid.DataSource = Surveys; QuestionsGrid.DataBind(); }
protected void gvList_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e) { TextBox tbName = null; Label lblName = null; if (e.Row.RowType == DataControlRowType.DataRow) { DnnImageButton btnUp = (DnnImageButton)e.Row.FindControl("btnUp"); btnUp.CommandArgument = e.Row.RowIndex.ToString(); DnnImageButton btnDown = (DnnImageButton)e.Row.FindControl("btnDown"); btnDown.CommandArgument = e.Row.RowIndex.ToString(); if (gvList.EditIndex != -1) { btnUp.Visible = false; btnDown.Visible = false; } else if (e.Row.RowIndex == 0) { btnUp.Visible = false; btnDown.Style.Add("margin-left", "24px"); } Control btnEdit = e.Row.FindControl("btnEdit"); Control btnDelete = e.Row.FindControl("btnDelete"); Control btnCancel = e.Row.FindControl("btnCancel"); Control btnUpdate = e.Row.FindControl("btnUpdate"); if ((e.Row.RowState & DataControlRowState.Edit) != 0) { tbName = (TextBox)e.Row.FindControl("tbName"); if (tbName != null) { tbName.Text = ((CategoryInfo)e.Row.DataItem).Category; } btnEdit.Visible = false; btnDelete.Visible = false; btnCancel.Visible = true; btnUpdate.Visible = true; } else { lblName = (Label)e.Row.FindControl("lblName"); if (lblName != null) { lblName.Text = ((CategoryInfo)e.Row.DataItem).Category; } btnEdit.Visible = true; btnDelete.Visible = true; btnCancel.Visible = false; btnUpdate.Visible = false; } } }
protected void DeleteImage_Click(object sender, EventArgs e) { DnnImageButton deleteImage = (DnnImageButton)sender; int surveyOptionID = Convert.ToInt32(deleteImage.CommandArgument); List <SurveyOptionsInfo> answers = Answers; answers.Remove(answers.Find(so => so.SurveyOptionID == surveyOptionID)); Answers = answers; AnswersGrid.DataSource = Answers; AnswersGrid.DataBind(); }
protected void EditImage_Click(object sender, EventArgs e) { DnnImageButton editImage = (DnnImageButton)sender; SurveyOptionsInfo surveyOption = SurveyOptionsController.Get(Convert.ToInt32(editImage.CommandArgument)); if (surveyOption != null) { SurveyOptionID = surveyOption.SurveyOptionID; SurveyOption = surveyOption; AnswerTextBox.Text = surveyOption.OptionName; CorrectAnswerCheckBox.Checked = surveyOption.IsCorrect; AddAnswerButton.Visible = false; UpdateAnswerButton.Visible = true; } }