You must Sign In to post a response.

how to open pdf in gridview hyperlink

i hv some code below

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
 
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Style="z-index: 100;
left: 298px; position: absolute; top: 318px" Text="Button" />
<asp:TextBox ID="TextBox1" runat="server" Style="z-index: 101; left: 624px; position: absolute;
top: 168px"></asp:TextBox>
   
<asp:GridView ID="GridView1" runat="server" Style="z-index: 103; left: 203px; position: absolute;
top: 116px">
<Columns>
<asp:HyperLinkField HeaderText ="select" Text ="select" NavigateUrl ="~/TPC scan project/fw9_7.pdf"/>
<asp:HyperLinkField HeaderText ="select1" Text="select1" NavigateUrl="~/TPC scan project/scan-300dp.pdf" />
<asp:HyperLinkField AccessibleHeaderText ="select3" Text ="abc" NavigateUrl ="~/TPC scan project/Sheet1$.xls" />

</Columns>
</asp:GridView>
</div>
</form>
</body>
</html>


and desin part i hv one button,one text box and one gridview,coding r below


using System;
using System.Data;
using System.Data.OleDb;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
{
OleDbConnection con = new OleDbConnection("Provider=MSDAORA.1;Password=singh;User ID=abhishek;Data Source=orcl;Persist Security Info=False");
protected void Page_Load(object sender, EventArgs e)
{

}

protected void Button1_Click(object sender, EventArgs e)
{
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter("select ename,sal,job,empno from emp where ename LIKE '" + TextBox1.Text + "%'", con);
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}
}




data is display in gridview properly but when i click on 1st column hyperlink(select) it will open pdf ok,when i click 2nd row hyperlink its also open same pdf.i know that why coz i define there pdf path,
but i hv lots of pdf file, i want in each row select(hyperlink) will be there and different-different pdf will be open.

plz reply below
abhishek_singh156@yahoo.com


Comments

No responses found. Be the first to comment...


Sign In to post your comments