0

okay guys here is a thing i am new in asp.net and just love toying with technology and trying to learn asp.net through creating persnal projects.

i am trying to create website that will basically take users info and users information and then store that in the data base. once that done and they are registered they will then proceed to a new page that is called portfolio. here i want the page to display all the photos that are saved in the folder directory. with the paths stored in the datbase. after that i when a user clicks a photo it takes him to a page where the photo is displayed in the middle and then all the information that the user has uploaded will be displayed after that .

this is my first project in web develpment and before that i had no pior knowlege of asp andn some rudimentary knowlege of c#. the thing is that i have been able to connect the database and store all the info and i have been able to extract all the info and display it in the template page simillary i have been able to display all the pictures by hard coding and using asp url tool. but i want to do that dynamically like when the page loads i want the page to fisrt gather all the pics and show that on the page. i heard that repeater class is used for it and i am figuring out how that works. but the thing is that repeater class turn that pic to the url so that when i click on that photo it takes me to a new page (template page ) where then i am able to display all the info.

i am not asking for the code all i am asking is a simple nudge in the right direction.

3
Contributors
6
Replies
31
Views
2 Years
Discussion Span
Last Post by A.Muqeetkhan
1

The repeater control is the right way to go. The only thing I would suggest is to think about how you want the image link to work. Personally, I would include the member ID for the photo in the link so the profile page reads the ID from the POST or the query parameters and uses that to extract the data from the database.
e.g. the naviagte URL for the image might be href='profile.aspx?id=109'

0

i heard that repeater class is used for it and i am figuring out how that works. but the thing is that repeater class turn that pic to the url so that when i click on that photo it takes me to a new page (template page ) where then i am able to display all the info.

Having some trouble understanding what you mean here. What is it exactly you want to happen when you click on an image?

0

Having some trouble understanding what you mean here. What is it exactly you want to happen when you click on an image?

?

?

image

well wahat i want is that if the image is clicked it should redirect me to a new page that should display the information of that guy or girl of whome the picture was selected

ps:i am sorry if you are having difficulty understanding my question english is some thing i am still learing (apart from programming).

0

actaully thanks all of you guy i have got it done

here is the code that i wrote

<asp:Repeater
                ID="Repeater1"
                runat="server">
                <ItemTemplate>
                   <%-- <asp:Image ID="Image1" Width="200px" ImageUrl='<%# Container.DataItem %>' runat="server" />--%>
                    <asp:HyperLink ID="HyperLink1" runat="server" ImageUrl='<%# Container.DataItem %>' NavigateUrl="~/Default.aspx" ImageHeight="300"></asp:HyperLink>

                </ItemTemplate>
            </asp:Repeater>

and this is the behind the page code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;

namespace try_and_bullshit_website_testing_arenea
{
    public partial class photos : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                Repeater1.DataSource = GetPhotos();
                Repeater1.DataBind();
            }
        }

       public List<String> GetPhotos()
    {
        List<string> photos = new List<string>();
        string photoPath = MapPath("~/Photos");
        string[] files = Directory.GetFiles(photoPath);
        foreach (string photo in files)
            photos.Add("~/Photos/" + Path.GetFileName(photo));
        return photos;
    }     
 }

but guysi was wondering if you can help me and tell me if there is a more efficinet way of doing the same thing.

1

ps:i am sorry if you are having difficulty understanding my question english is some thing i am still learing (apart from programming).

Your english is fine. great job!

The code behind may or may not be correct...i'm not in front of Visual studio to do testing.

What you need to do is build the hyperlinks to include a querystring... which could be the user's id (maybe their profile Id or something). for example... the hyperlink could be something like just like hericles suggested.

 profile.aspx?id=109

then, on the profile.aspx page, in your code behind, page load, read the querystring..

 string profile = Request.QueryString["id"];

now that you have the value (you probably need to do some validating to ensure you have a valid value), use this value to query the database, then take the results and build out your profile page (info about the user).

Does this make sense?

Are you just having trouble with the repeater?

0

now that you have the value (you probably need to do some validating to ensure you have a valid value), use this value to query the database, then take the results and build out your profile page (info about the user).

Does this make sense?

actually i got the repeater thing correct ,thanks you all so much for your help. now i was just looking into "building the hyperlinks to include a querystring" thing. il ask further questions when il get stuck

Edited by A.Muqeetkhan: grammer

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.