コード例 #1
0
    protected void gvAdminFAQ_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        int         result  = 0;
        FAQ         aFAQ    = new FAQ();
        GridViewRow row     = (GridViewRow)gvAdminFAQ.Rows[e.RowIndex];
        string      id      = gvAdminFAQ.DataKeys[e.RowIndex].Value.ToString();
        string      fid     = ((TextBox)row.Cells[0].Controls[0]).Text;
        string      fanswer = ((TextBox)row.Cells[3].Controls[0]).Text;

        result = aFAQ.FAQUpdate(fid, fanswer);
        if (result > 0)
        {
            Response.Write("<script>alert('Answer updated successfully');</script>");
            Response.Redirect("~/AdminPages/AdminFAQ.aspx");
        }
        else
        {
            Response.Write("<script>alert('Answer not updated');</script>");
        }
        gvAdminFAQ.EditIndex = -1;
        bind();
    }