Click here to Skip to main content
15,885,032 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
I am making a project for my high school studies in the field of asp.net and css (c#).
As you probably understand i'm not very good at this subject, as a matter of a fact i'm a total beginner.
My goal is to create a picture gallery (in a website) that gets the path of the pictures from a database using a datalist.
after a while i understood that too many pictures will cause problems in the website.
so I thought about paging, but as I understood after a short investigation online there is no paging function for Datalists. So... i would be really glad if any of you can help me understanding how may i do such a thing (use paging with datalists).
If any of you can write the exact code for me so i can check it out it might help me understand even more.

Additional Information: I'm using microsoft web developer 2010 express, I'm really new to this so an explanation in addition to the code would be great (if possible).

ASP/HTML CODE:
ASP.NET
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Gallery.aspx.cs" Inherits="Gallery" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
    <asp:DataList ID="DataList1" runat="server" RepeatColumns="4" CellSpacing="10" HorizontalAlign="Center" >
        <ItemTemplate>
           
                <img src='<%# Eval("Path") %>' height="150" width="150" />
           
        </ItemTemplate>

    </asp:DataList>

</asp:Content>


css code:
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

public partial class Gallery : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        DataSet ds = new DataSet();
        ds = DAL.ShowAllPictures();
        DataList1.DataSource = ds;
        DataList1.DataBind();


    }



}


Thank you in advance, Assaf.
Posted
Updated 25-Feb-13 5:01am
v2

I hope it's allowed by the rules to comment on my own thread.
This doesn't look SO hard, i know... but it's hard for me and
any tiny tip would help me alot.
 
Share this answer
 
Comments
Sandeep Mewara 25-Feb-13 13:52pm    
Yes, comment is allowed but not a solution which is a comment. You have posted a comment as solution.

You can use 'Have a question or comment?' link to add comment. OR use 'Improve Question' to edit/update question at any point of time.
Rorschachs 26-Feb-13 4:43am    
That's clear sir. :P
 
Share this answer
 
Comments
Rorschachs 26-Feb-13 4:42am    
First of all, thank you for the fast response.
I know it's allot to ask for but I still doesn't understand how can I make the paging for my page.
I tried, but as I told you i'm pretty new to programming.
any more help would be great :)
Sandeep Mewara 26-Feb-13 5:25am    
I shared direct articles explaining how it can be done with sample codes. If that was not too helpful, I doubt it would be easy to get more online help. Catch someone in person.
Rorschachs 26-Feb-13 6:26am    
Ok, thank you for your help.. I will try to understand. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900