protected void lnkbtnAddPage_Click(object sender, EventArgs e)
    {
        try
        {
            GroupPages grp = new GroupPages();
            grp.intResourceID = 0;
            grp.vchName       = txtPageNamefooter.Text + "(" + ddlTypeFooter.SelectedItem.Text + ")";
            grp.intParentID   = Convert.ToInt32(ddlTypeFooter.SelectedItem.Value);
            grp.vchPath       = txtPagePathfooter.Text;

            GroupPages.InsertUpdateResources(grp);

            loadPages();
        }
        catch (Exception ex)
        {
            new SqlLog().InsertSqlLog(0, "Addpages.aspx.lnkbtnAddPage_Click", ex);
        }
    }
    protected void gvPages_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        try
        {
            TextBox      txtPageName   = (TextBox)gvPages.Rows[e.RowIndex].FindControl("txtPageName");
            DropDownList ddlDomainName = gvPages.Rows[e.RowIndex].FindControl("ddlType") as DropDownList;
            TextBox      txtPagePath   = (TextBox)gvPages.Rows[e.RowIndex].FindControl("txtPagePath");

            GroupPages grp = new GroupPages();
            grp.intResourceID = Convert.ToInt32(gvPages.DataKeys[e.RowIndex].Values[0].ToString());
            grp.vchName       = txtPageName.Text + "(" + ddlDomainName.SelectedItem.Text + ")";
            grp.intParentID   = Convert.ToInt32(ddlDomainName.SelectedItem.Value);
            grp.vchPath       = txtPagePath.Text;

            GroupPages.InsertUpdateResources(grp);

            gvPages.EditIndex = -1;
            loadPages();
        }
        catch (Exception ex)
        {
            new SqlLog().InsertSqlLog(0, "Addpages.aspx.gvPages_RowUpdating", ex);
        }
    }
    protected void gvPages_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        try
        {
            if (e.CommandName == "Edit")
            {
                pageid = Convert.ToInt32(e.CommandArgument);
            }

            else if (e.CommandName == "Delete")
            {
                if (Convert.ToBoolean(hdfactive.Value) == true)
                {
                    GroupPages.ActiveDeactiveGroupPage(Convert.ToInt32(e.CommandArgument), false);
                }
                else
                {
                    GroupPages.ActiveDeactiveGroupPage(Convert.ToInt32(e.CommandArgument), true);
                }
                loadPages();
            }
            else if (e.CommandName == "AddMore")
            {
                LinkButton lnkbtnAddMorePage = gvPages.FooterRow.FindControl("lnkbtnAddMore") as LinkButton;
                LinkButton lnkbtnAddPage     = gvPages.FooterRow.FindControl("lnkbtnAddPage") as LinkButton;
                LinkButton lnkbtnCancelPage  = gvPages.FooterRow.FindControl("lnkbtnCancelPage") as LinkButton;
                lnkbtnAddPage.Visible     = true;
                lnkbtnAddMorePage.Visible = false;
                lnkbtnCancelPage.Visible  = true;

                TextBox      txtPageNamefoot   = gvPages.FooterRow.FindControl("txtPageNamefooter") as TextBox;
                DropDownList ddlDomainNamefoot = gvPages.FooterRow.FindControl("ddlTypeFooter") as DropDownList;
                TextBox      txtPagePathfoot   = gvPages.FooterRow.FindControl("txtPagePathfooter") as TextBox;

                txtPageNamefoot.Visible   = true;
                ddlDomainNamefoot.Visible = true;
                txtPagePathfoot.Visible   = true;

                ddlDomainNamefoot.Items.Insert(0, new ListItem("--Select Domain--", "0"));
                Utils.GetLookUpData <DropDownList>(ref ddlDomainNamefoot, LookUps.MainResources, true);
            }
            else if (e.CommandName == "CancelPage")
            {
                gvPages.EditIndex = -1;
                loadPages();
            }
            else if (e.CommandName == "Insert")
            {
                TextBox      txtPageName   = gvPages.FooterRow.FindControl("txtPageNamefooter") as TextBox;
                DropDownList ddlDomainName = gvPages.FooterRow.FindControl("ddlTypeFooter") as DropDownList;
                TextBox      txtPagePath   = gvPages.FooterRow.FindControl("txtPagePathfooter") as TextBox;

                GroupPages grp = new GroupPages();
                grp.vchName       = txtPageName.Text;
                grp.vchPath       = txtPagePath.Text;
                grp.intParentID   = Convert.ToInt32(ddlDomainName.SelectedItem.Value);
                grp.intResourceID = 0;

                GroupPages.InsertUpdateResources(grp);

                loadPages();
            }
        }
        catch (Exception ex)
        {
            new SqlLog().InsertSqlLog(0, "Addpages.aspx.gvPages_RowCommand", ex);
        }
    }