コード例 #1
0
    protected void GridView3_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        try
        {
            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)GridView3.Rows[_selectedIndex].Cells[0].FindControl("grdID1");
                    Image lblPhtoPath = (Image)GridView3.Rows[_selectedIndex].Cells[0].FindControl("grdImg1");

                    if (DropDownList1.SelectedItem.Text == "Historical Spots" && DropDownList3.SelectedItem.Text != "Select")
                    {
                        GeneralBAL ph = new GeneralBAL();
                        a = ph.DeleteSpotMapphoto(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);
                    }
                }
            }
        }
        catch
        {
        }
    }
コード例 #2
0
    protected void GridView3_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        try
        {
            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)GridView3.Rows[_selectedIndex].Cells[0].FindControl("grdID1");
                    Image lblPhtoPath = (Image)GridView3.Rows[_selectedIndex].Cells[0].FindControl("grdImg1");

                    if (DropDownList1.SelectedItem.Text == "Historical Spots" && DropDownList3.SelectedItem.Text != "Select")
                    {
                        GeneralBAL ph = new GeneralBAL();
                        a = ph.DeleteSpotMapphoto(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);

                }
            }
        }
        catch
        {
        }
    }