Example #1
0
    protected void Gridview_OnRowCommand(object sender, GridViewCommandEventArgs e)
    {
        string _commandName;

        if (e.CommandArgument.ToString() == "Next" || e.CommandArgument.ToString() == "Last" || e.CommandArgument.ToString() == "First" || e.CommandArgument.ToString() == "Prev")
        {
        }
        else
        {
            // Get the selected index and the command name
            int _selectedIndex = int.Parse(e.CommandArgument.ToString());

            _commandName = e.CommandName;
            if (_commandName == "PhotoDelete")
            {
                int   a           = 0;
                Label lpid        = (Label)GridView1.Rows[_selectedIndex].Cells[0].FindControl("grdID");
                Image lblPhtoPath = (Image)GridView1.Rows[_selectedIndex].Cells[0].FindControl("grdImg");

                if (ddlColumn.SelectedItem.Text != "Select" && DropDownList1.SelectedItem.Text == "LP" && ddlColumn1.SelectedItem.Text != "Select")
                {
                    GeneralBAL ph = new GeneralBAL();
                    a = ph.DeleteLPPhoto(lpid.Text);
                }
                else if (DropDownList1.SelectedItem.Text == "Festivals" && ddlColumn.SelectedItem.Text != "Select")
                {
                    GeneralBAL ph = new GeneralBAL();
                    a = ph.DeleteFestivalPhoto(lpid.Text);
                }
                else if (DropDownList1.SelectedItem.Text == "Historical Spots" && ddlColumn.SelectedItem.Text != "Select")
                {
                    GeneralBAL ph = new GeneralBAL();
                    a = ph.DeleteSpotPhoto(lpid.Text);
                }

                if (a != 0)
                {
                    string pt = Server.MapPath("");
                    string st = lblPhtoPath.ImageUrl.ToString().Remove(0, 1).Replace('/', '\\');
                    System.IO.File.Delete(pt + st);
                    Page.ClientScript.RegisterStartupScript(typeof(Page), "key", "alert('Photo Deleted.');location='GalleryManager.aspx';", true);
                }
                else
                {
                    Page.ClientScript.RegisterStartupScript(typeof(Page), "key", "alert('Contact Administrator.');location='GalleryManager.aspx';", true);
                }
            }
        }
    }
Example #2
0
    protected void Gridview_OnRowCommand(object sender, GridViewCommandEventArgs e)
    {
        string _commandName;
        if (e.CommandArgument.ToString() == "Next" || e.CommandArgument.ToString() == "Last" || e.CommandArgument.ToString() == "First" || e.CommandArgument.ToString() == "Prev")
        {
        }
        else
        {
            // Get the selected index and the command name
            int _selectedIndex = int.Parse(e.CommandArgument.ToString());

            _commandName = e.CommandName;
            if (_commandName == "PhotoDelete")
            {
                int a = 0;
                Label lpid = (Label)GridView1.Rows[_selectedIndex].Cells[0].FindControl("grdID");
                Image lblPhtoPath = (Image)GridView1.Rows[_selectedIndex].Cells[0].FindControl("grdImg");

                if (ddlColumn.SelectedItem.Text != "Select" && DropDownList1.SelectedItem.Text == "LP" && ddlColumn1.SelectedItem.Text != "Select")
                {
                    GeneralBAL ph = new GeneralBAL();
                    a = ph.DeleteLPPhoto(lpid.Text);
                }
                else if (DropDownList1.SelectedItem.Text == "Festivals" && ddlColumn.SelectedItem.Text != "Select")
                {
                    GeneralBAL ph = new GeneralBAL();
                    a = ph.DeleteFestivalPhoto(lpid.Text);
                }
                else if (DropDownList1.SelectedItem.Text == "Historical Spots" && ddlColumn.SelectedItem.Text != "Select")
                {
                    GeneralBAL ph = new GeneralBAL();
                    a = ph.DeleteSpotPhoto(lpid.Text);
                }

                if (a != 0)
                {
                    string pt = Server.MapPath("");
                    string st = lblPhtoPath.ImageUrl.ToString().Remove(0, 1).Replace('/', '\\');
                    System.IO.File.Delete(pt + st);
                    Page.ClientScript.RegisterStartupScript(typeof(Page), "key", "alert('Photo Deleted.');location='GalleryManager.aspx';", true);
                }
                else
                    Page.ClientScript.RegisterStartupScript(typeof(Page), "key", "alert('Contact Administrator.');location='GalleryManager.aspx';", true);

            }
        }
    }