protected void btnAdd_Click(object sender, EventArgs e) { string Question = ""; string Answer = ""; if (txtQuestion.Text.Trim().Length > 0) { Question = txtQuestion.Text.Trim(); } else { lblMsg.Text = "Enter Question..."; } txtQuestion.Focus(); if (txtAnswer.Text.Trim().Length > 0) { Answer = txtAnswer.Text.Trim(); } else { lblMsg.Text = "Enter Answer..."; } txtAnswer.Focus(); FaqBusinessLayer.InsertFaq(Question, Answer); lblMsg.Text = "Question Added Successfully...!"; txtQuestion.Focus(); }
protected void btnUpdate_Click(object sender, EventArgs e) { int Faqid = 0; Faqid = int.Parse(Request["cid"]); string Question = ""; string Answer = ""; if (txtQuestion.Text.Trim().Length > 0) { Question = txtQuestion.Text.Trim(); } else { lblMsg.Text = "Enter Question..."; } txtQuestion.Focus(); if (txtAnswer.Text.Trim().Length > 0) { Answer = txtAnswer.Text.Trim(); } else { lblMsg.Text = "Enter Answer..."; } txtAnswer.Focus(); FaqBusinessLayer.UpdateQuestion(Faqid, Question, Answer); lblMsg.Text = "Data Updated Successfully...!"; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { GridView1.DataSource = FaqBusinessLayer.ShowQuestion(); GridView1.DataBind(); } }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { int FaqId = 0; Label l; l = (Label)GridView1.Rows[0].FindControl("lblid"); FaqId = int.Parse(l.Text); //Response.Write("<script>confirm('R U Sure?')</script>"); //lblMsg.Text = "Country Deleted Successfully"; FaqBusinessLayer.DeleteQuestion(FaqId); ShowQuestion(); }
protected void Page_Load(object sender, EventArgs e) { if (Session["Name"] == null) { Response.Redirect("~/Admin/frmAdminLogin.aspx"); } DataSet ds = new DataSet(); if (!IsPostBack) { int FaqId = 0; FaqId = int.Parse(Request["cid"]); ds = FaqBusinessLayer.ShowQuestionById(FaqId); txtQuestion.Text = ds.Tables[0].Rows[0][0].ToString(); txtAnswer.Text = ds.Tables[0].Rows[0][1].ToString(); } }
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { try { if (e.CommandName == "Select") { int faqid = 0; faqid = Convert.ToInt32(e.CommandArgument.ToString()); DataSet ds = new DataSet(); ds = FaqBusinessLayer.ShowAnswerByFaqId(faqid); lblAnswer.Text = ds.Tables[0].Rows[0][0].ToString(); } } catch (Exception) { throw; } }
protected void btnDelete_Click(object sender, EventArgs e) { int FaqId = 0; CheckBox chk; foreach (GridViewRow gr in GridView1.Rows) { chk = (CheckBox)gr.FindControl("chkid"); if (chk.Checked == true) { Label l1; l1 = (Label)gr.FindControl("lblid"); FaqId = int.Parse(l1.Text); FaqBusinessLayer.DeleteQuestion(FaqId); ShowQuestion(); } } }
public void ShowQuestion() { GridView1.DataSource = FaqBusinessLayer.ShowQuestion(); GridView1.DataBind(); }