| Server IP : 104.21.93.206  /  Your IP : 172.69.58.4 Web Server : Microsoft-IIS/10.0 System : Windows NT WAVE 10.0 build 20348 (Windows Server 2016) AMD64 User : IWPD_458(indias) ( 0) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : D:/inetpub/vhosts/indiasmartbazaar.com/pimsharyana.in/ | 
| Upload File : | 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Net;
public partial class result : System.Web.UI.Page
{
    SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ConnectionString);
    protected void Page_Load(object sender, EventArgs e)
    {
        if(!IsPostBack)
        {
            getresult();
        }
    }
    protected void Page_Init(object sender, EventArgs e)
    {
        SqlCommand cmd = new SqlCommand("Select * from tbl_result  Order By ID ASC", con);
        SqlDataAdapter DA = new SqlDataAdapter(cmd);
        DataTable Dt = new DataTable();
        DA.Fill(Dt);
        if (Dt.Rows.Count > 0)
        {
            gridncert.DataSource = Dt;
            gridncert.DataBind();
        }
    }
    private void getresult()
    {
        SqlCommand cmd = new SqlCommand("Select * from tbl_result  Order By ID ASC", con);
        SqlDataAdapter DA = new SqlDataAdapter(cmd);
        DataTable Dt = new DataTable();
        DA.Fill(Dt);
        if (Dt.Rows.Count > 0)
        {
            gridncert.DataSource = Dt;
            gridncert.DataBind();
        }
    }
    protected void Button1_Command(object sender, CommandEventArgs e)
    {
        //String ID = e.CommandArgument.ToString();
        //Response.Redirect("ReprintOPD.aspx?ID=" + ID);
        string[] arg = new string[2];
        arg = e.CommandArgument.ToString().Split(';');
        String filePath1 = arg[0];
        String filePath = Server.MapPath(filePath1);
        String permission = arg[1];
        if (permission == "Yes")
        {
            //FileInfo file = new FileInfo(filePath);
            //// Clear Rsponse reference  
            //Response.Clear();
            //// Add header by specifying file name  
            //Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
            //// Add header for content length  
            //Response.AddHeader("Content-Length", file.Length.ToString());
            //// Specify content type  
            //Response.ContentType = "text/plain";
            //// Clearing flush  
            //Response.Flush();
            //// Transimiting file  
            //Response.TransmitFile(file.FullName);
            //Response.End();
            //String  = Server.MapPath(filePath1);
            string path = Server.MapPath(filePath1);
            WebClient client = new WebClient();
            Byte[] buffer = client.DownloadData(path);
            if (buffer != null)
            {
                Response.ContentType = "application/pdf";
                Response.AddHeader("content-length", buffer.Length.ToString());
                Response.BinaryWrite(buffer);
            }
            //}
            //else
            //{
            //}
        }
        else
        {
          
        }
        //String filePath = e.CommandArgument.ToString();
    }
    protected void btnview_Command(object sender, CommandEventArgs e)
    {
        string[] arg = new string[1];
        arg = e.CommandArgument.ToString().Split(';');
        String filePath1 = arg[0];
        String filePath = Server.MapPath(filePath1);
     
            //FileInfo file = new FileInfo(filePath);
            //// Clear Rsponse reference  
            //Response.Clear();
            //// Add header by specifying file name  
            //Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
            //// Add header for content length  
            //Response.AddHeader("Content-Length", file.Length.ToString());
            //// Specify content type  
            //Response.ContentType = "text/plain";
            //// Clearing flush  
            //Response.Flush();
            //// Transimiting file  
            //Response.TransmitFile(file.FullName);
            //Response.End();
            //String  = Server.MapPath(filePath1);
            //string path = Server.MapPath(filePath1);
            //WebClient client = new WebClient();
            //Byte[] buffer = client.DownloadData(path);
            Response.Redirect("https://drive.google.com/viewerng/viewer?embedded=true&url=https://https://pimsharyana.in//" + filePath1);
            //if (buffer != null)
            //{
            //    Response.ContentType = "application/pdf";
            //    Response.AddHeader("content-length", buffer.Length.ToString());
            //    Response.BinaryWrite(buffer);
            //}
            //}
            //else
            //{
            //}
      
    }
}