TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Saswat Routroy
NA
1
4.2k
Dynamic ImageButton Under DataList redirecting to the Image in Folder
Jan 2 2012 5:02 AM
Friends, i have a problem and i wish to have some help........ I am creating a matrimony site. When a person is registering, a folder is created by his/her username folder, ex- say if a person is using Damu234 as username then a folder will be created with path "~/Candidate_Pics/Male/Damu234" where Damu234 is a male candidate...if a female candidate is registering, with username Supriti36 then a folder with path "~/Candidate_Pics/Female/Supriti36" will be created.....
Now am using Session["Sex"], when Session["Sex"]=="Male" then "~Candidate_Pics/" + Convert.ToString(Session["Sex"]) + "/" will be traversed....
i'm using one image and one hyperlink field under the DataList control, i want to use ImageButton in place of Image so that on clicking ImageButton, the definit picture from the folder will be shown,
and i want it to happen at runtime, since based on session["sex"] and username, the userfolder having the pics will be selected.....
here's my aspx design code:
Div
<html>
<div>
<asp:DataList ID="dtlist" runat="server" RepeatColumns="4" CellPadding="5">
<ItemTemplate>
<asp:Image Width="100" ID="ImagePic" ImageUrl='<%#Container.DataItem%>' runat="server"/>
<br />
<asp:HyperLink ID="HyperLink1" Text='<%# Container.DataItem %>' NavigateUrl='<%# Container.DataItem %>' runat="server" />
</ItemTemplate>
<ItemStyle BorderColor="Brown" BorderStyle="dotted" BorderWidth="3px" HorizontalAlign="Center" VerticalAlign="Bottom" />
</asp:DataList>
</div>
</html>
and my aspx.cs code::
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
BindDataList();
}
}
protected void BindDataList()//shows the pics from the user folder
{
string[] list = Directory.GetFiles(Server.MapPath("/Candidate_Pics/" + Convert.ToString(Session["Sex"]) + "/" + txt_u_name.Text + "/"));
var aList = from fileName in Directory.GetFiles(Server.MapPath("/Candidate_Pics/" + Convert.ToString(Session["Sex"]) + "/" + txt_u_name.Text + "/"))
select string.Format("/Candidate_Pics/" + Convert.ToString(Session["Sex"]) + "/" + txt_u_name.Text + "/{0}", Path.GetFileName(fileName));
dtlist.DataSource = aList;
dtlist.DataBind();
}
i'm not using any database regarding folder pics, is there a way so that i can replace the Image inside the DataList by a ImageButton, so that when i click the button, it opens the coressponding image in a new page, or rather in a lightbox.....also i want to use a delete button inside the Datalist along with the ImageButton, so that i can delete the corresponding image from the folder....Can this be done and without using the concept of database?? Any help is appreciated.....
Reply
Answers (
1
)
How to bind two table in gridview in asp.net
How to break the long word in all browsers