I am working on a website. In this, I have to display a name of file uploaded by admin(not its file name) as link. when a user click on link, it will open saved file from database(pdf files saved as binary files).
I have used a datalist as-
Width="498px">
and in .cs file code is
protected void Bind_DataList()
{
string strCon = ConfigurationManager.ConnectionStrings["MyDBConnectionString"].ConnectionString.ToString();
SqlConnection con = new SqlConnection(strCon);
con.Open();
SqlDataAdapter da = new SqlDataAdapter("select * from Orders_Table order by ID desc", con);
DataTable dt = new DataTable();
PagedDataSource pd = new PagedDataSource();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
pd.DataSource = dt.DefaultView;
DL_Circular.DataSource = pd;
DL_Circular.DataBind();
}
else
{
DL_Circular.Visible = false;
}
con.Close();
}
I am trying to give a onclick event, that will conver binary to pdf format and open pdf file in new tab. But it fails.
Please help me.
Thank you,
Anuradha ChavanPosted Nov 20, 2013, 4:07 AM
when i run a program resuls that, Failed to load pdf
Jaganathan BantheswaranPosted Nov 20, 2013, 2:22 AM
Make that link's target="_blank" & try to set like this,
Response.ContentType = "Application/pdf";
Response.BinaryWrite(pdffilebytes);