How can i add a link below the book and readcontents of the book from the database
please help
Imports System.Data
Imports System.IO
Imports System.Data.SqlClient
Imports System.Web.UI.WebControls
Imports System.Web.UI
Imports System.Web
Imports System.Linq
Imports System.Collections.Generic
Imports System
Public Class TrendingBooks
Inherits System.Web.UI.Page
Private sqlda As New SqlDataAdapter()
Private dt As New DataTable()
Dim constr As String = ConfigurationManager.ConnectionStrings("SLISConnectionString").ConnectionString
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
BindDataList()
End If
End Sub
Private Sub BindDataList()
Dim conn As New SqlConnection(constr)
conn.Open()
sqlda = New SqlDataAdapter("SELECT * FROM MyImageGallery", conn)
dt = New DataTable()
sqlda.Fill(dt)
sqlda.Dispose()
dtListImageGallery.DataSource = dt
dtListImageGallery.DataBind()
conn.Close()
End Sub
Protected Sub btnUpload_Click(sender As Object, e As EventArgs)
Dim conn As New SqlConnection(constr)
If imgFileUpload.PostedFile IsNot Nothing Then
Dim imagename As String = Path.GetFileName(imgFileUpload.PostedFile.FileName)
imagename = imagename.Split("."c)(0).ToString()
Dim pathname As String
pathname = Server.MapPath("~\ImageGallery\") + DateTime.Now.ToString("ddMMyyhhmmsstt") + imgFileUpload.FileName
imgFileUpload.PostedFile.SaveAs(pathname)
Try
conn.Open()
Dim insquery As String = "Insert into MyImageGallery(ImageName,ImagePath) values('" + imagename + "','" + DateTime.Now.ToString("ddMMyyhhmmsstt") + imgFileUpload.FileName.ToString() + "')"
Dim cmd As New SqlCommand(insquery, conn)
cmd.ExecuteNonQuery()
conn.Close()
BindDataList()
Catch ex As Exception
Response.Write(ex.Message)
End Try
End If
End Sub
End Class
<form id="form2" runat="server">
<div>
<table>
<tr>
<td colspan="3">
<h2>Image Gallery</h2>
</td>
</tr>
<tr>
<td>Upload Image</td>
<td>
<asp:FileUpload ID="imgFileUpload" runat="server" />
</td>
<td>
<asp:Button ID="btnUpload" runat="server" Text="Upload" OnClick="btnUpload_Click" />
</td>
</tr>
</table>
</div>
<div id="divImageList" runat="server">
<asp:DataList ID="dtListImageGallery" runat="server" RepeatColumns="3" RepeatDirection="Horizontal"
Width="50%" BorderColor="#336699" BorderStyle="Solid" BorderWidth="2px">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("ImageName") %>' Font-Bold="True"
Font-Size="10pt" ForeColor="#336699" Width="100%" />
<br />
<asp:Image Width="100" ID="imgGallery" ImageUrl='<%# Bind("ImagePath", "~/ImageGallery/{0}") %>'
runat="server" />
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Top" />
</asp:DataList>
</div>
</form>