public void BindImages()
{
string[] filePaths = Directory.GetFiles(Server.MapPath("~/Images/"));
List<ListItem> files = new List<ListItem>();
foreach (string filePath in filePaths)
{
files.Add(new ListItem(Path.GetFileName(filePath), filePath));
}
dListImages.DataSource = files;
dListImages.DataBind();
}
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="FeedbackList.aspx.cs" Inherits="ConfirmUserFeedback" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<link href="StyleSheet.css" rel="stylesheet" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<style type="text/css">
.imgthumb {
height: 100px;
width: 100px;
}
.imgdiv {
background-color: White;
margin-left: auto;
margin-right: auto;
padding: 10px;
border: solid 1px #c6cfe1;
height: 500px;
width: 450px;
}
</style>
<script type="text/javascript">
$(function () {
$("img.imgthumb").click(function (e) {
var enlargeImage = '<img src=images/' + $(this).attr("alt") + '></img>';
$('#divImgEnlarge')
.html($(enlargeImage)
.animate({ height: '200', width: '250' }, 500));
});
});
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="masterpage_body" Runat="Server">
<table cellpadding="1" cellspacing="1" width="880px" align="center" class="BlueBorder"
style="background: White;">
<tr>
<td>
</td>
</tr>
<tr>
<td>
<asp:DataList ID="dListImages" runat="server" RepeatColumns="1">
<ItemTemplate>
<br />
<table border="1">
<tr>
<td>
<img alt='<%#Eval("Text") %>' src='<%#Eval("Value") %>' class="imgthumb" /></td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
</td>
</tr>
<tr>
<td style="text-align: center; vertical-align: central; ">
<div id="divImgEnlarge"></div>
</td>
</tr>
</table>
</asp:Content>
this code gets all the data from my image file.
Is it possible to link it to my data to retrieve image1, 2 & 3 when id=@id?
Please Help,
Here is my database
CREATE TABLE [dbo].[UserFeedback] (
[FeedbackId] INT IDENTITY (1, 1) NOT NULL,
[NickName] VARCHAR (10) NOT NULL,
[Email] VARCHAR (40) NOT NULL,
[Conduct] VARCHAR (50) NOT NULL,
[OtherFeedback] VARCHAR (MAX) NOT NULL,
[Image1] VARCHAR (30) NOT NULL,
[Image2] VARCHAR (30) NOT NULL,
[Image3] VARCHAR (30) NOT NULL,
[Status] VARCHAR (20) NULL,
CONSTRAINT [PK_UserFeedback] PRIMARY KEY CLUSTERED ([FeedbackId] ASC)
);
Thank you so much.
Love this website and your fast respond.