How to link to PDF files from datalist? [modified]
-
i like to display report names in a data list and when the user clicks open the corresponding PDF file. all the reports are in PDF format. Report 1 Report 2 Report 3 Report 4 Report 5 how can i do this? i am saving pdf files path in database(http://www.mysite.com/reports/Report1.pdf) my current code shows the report name but when i click it doesn't go anywhere.
<asp:datalist id="DL1" runat="server" ItemStyle-BackColor="#c7c7c6" ItemStyle-BorderColor="#c7c7c6" CssClass="Titles"> <ItemTemplate> <asp:HyperLink Runat ="server" NavigateUrl ='<%#DataBinder.Eval(Container.DataItem, "ReportURL")%>' ID="Hyperlink1"> <%#DataBinder.Eval(Container.DataItem, "ReportName")%> </asp:HyperLink> </ItemTemplate> </asp:datalist>
code behindPrivate Sub GetReports() Dim objConnection As SqlConnection = New _ SqlConnection(ConfigurationManager.ConnectionStrings("MyDbConn").ToString()) objConnection.Open() Dim myCommand As New System.Data.SqlClient.SqlCommand() myCommand.Connection = objConnection myCommand.CommandText = "SelectReports" myCommand.CommandType = CommandType.StoredProcedure Dim param As New System.Data.SqlClient.SqlParameter() Dim myAdapter As New SqlDataAdapter(myCommand) myAdapter.Fill(DataSetReports) Dim reader As SqlDataReader = myCommand.ExecuteReader() DL1.DataSource = DataSetReports DL1.DataBind() objConnection.Close() End Sub
modified on Monday, January 25, 2010 1:21 AM
-
i like to display report names in a data list and when the user clicks open the corresponding PDF file. all the reports are in PDF format. Report 1 Report 2 Report 3 Report 4 Report 5 how can i do this? i am saving pdf files path in database(http://www.mysite.com/reports/Report1.pdf) my current code shows the report name but when i click it doesn't go anywhere.
<asp:datalist id="DL1" runat="server" ItemStyle-BackColor="#c7c7c6" ItemStyle-BorderColor="#c7c7c6" CssClass="Titles"> <ItemTemplate> <asp:HyperLink Runat ="server" NavigateUrl ='<%#DataBinder.Eval(Container.DataItem, "ReportURL")%>' ID="Hyperlink1"> <%#DataBinder.Eval(Container.DataItem, "ReportName")%> </asp:HyperLink> </ItemTemplate> </asp:datalist>
code behindPrivate Sub GetReports() Dim objConnection As SqlConnection = New _ SqlConnection(ConfigurationManager.ConnectionStrings("MyDbConn").ToString()) objConnection.Open() Dim myCommand As New System.Data.SqlClient.SqlCommand() myCommand.Connection = objConnection myCommand.CommandText = "SelectReports" myCommand.CommandType = CommandType.StoredProcedure Dim param As New System.Data.SqlClient.SqlParameter() Dim myAdapter As New SqlDataAdapter(myCommand) myAdapter.Fill(DataSetReports) Dim reader As SqlDataReader = myCommand.ExecuteReader() DL1.DataSource = DataSetReports DL1.DataBind() objConnection.Close() End Sub
modified on Monday, January 25, 2010 1:21 AM
No difference between link button in datagrid and link button in datalist. Something else is causing problem to u.
April Comm100 - Leading Live Chat Software Provider