Click here to Skip to main content
15,891,708 members

Paging function with a simple datalist.

Rorschachs asked:

Open original thread
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.
Tags: Database Development, Internet, Data binding, Dataset, Website, Paging

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



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