具有简单数据主义的分页功能。 [英] Paging function with a simple datalist.
问题描述
我正在为asp.net和css(c#)领域的高中学习做一个项目。
你可能已经明白我不是很擅长这个学科,事实上,我是一个初学者。
我的目标是创建一个图片库(在网站中),使用数据列表从数据库中获取图片的路径。
一段时间后我明白太多图片会导致网站出现问题。
所以我考虑过分页,但据我在网上进行了一次简短的调查后了解到,没有分页功能Datalists。所以...如果你们中的任何一个人能帮我理解我怎么做这样的事情(使用分析与数据专家),我真的很高兴。
如果有人能为我编写确切的代码所以我可以查看它可能会帮助我理解更多。
其他信息:我正在使用微软开发人员2010快递,我真的很新,所以除了代码之外的解释会很棒(如果可能的话)。
ASP / HTML代码:
<%@ Page 标题 = 语言 = C# MasterPageFile = 〜/ MasterPage.master AutoEventWireup = true CodeFile = Gallery.aspx.cs 继承 = 图库 %>
< asp:Content ID = Content1 ContentPlaceHolderID = ContentPlaceHolder1 Runat = 服务器 >
< / asp:内容 >
< asp:内容 ID = Content2 ContentPlaceHolderID = ContentPlaceHolder2 Runat = 服务器 >
< span class =code-keyword>< asp:DataList ID = DataList1 runat = server RepeatColumns = < span class =code-keyword> 4 CellSpacing = 10 HorizontalAlign = 中心 >
< ItemTemplate >
< img src =' <% #Eval( 路径)%> ' height = 150 width = 150 / >
< / ItemTemplate >
< / asp:DataList >
< / asp:Content >
css代码:
< pre lang =c#> 使用系统;
使用 System.Collections.Generic;
使用 System.Linq;
使用 System.Web;
使用 System.Web.UI;
使用 System.Web.UI.WebControls;
使用 System.Data;
使用 System.Data.SqlClient;
public partial class 图库:System.Web.UI.Page
{
受保护 void Page_Load( object sender,EventArgs e)
{
DataSet ds = new 数据集();
ds = DAL.ShowAllPictures();
DataList1.DataSource = ds;
DataList1.DataBind();
}
}
提前谢谢你,Assaf。
我希望规则允许评论我自己的帖子。
这看起来并不难,我知道......但这对我来说很难,并且
任何小小的提示都会对我有所帮助。
< blockquote>这里,下面的文章将帮助您了解如何实现该功能:
使用ASP.NET 2.0中的Datalist Control实现高效的数据分页 [ ^ ]
使用PagedDataSource类向Repeater或DataList添加分页支持 [ ^ ]
使用ASP.NET 2.0 DataList控件和ObjectDataSource进行高效的数据分页 [ ^ ]
试用!
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:
<%@ 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:
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.
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.
Here, following article will help you understand how to implement the feature:
Implementing Efficient Data Paging with the Datalist Control in ASP.NET 2.0[^]
Adding Paging Support to the Repeater or DataList with the PagedDataSource Class[^]
Efficient Data Paging with the ASP.NET 2.0 DataList Control and ObjectDataSource[^]
Try out!
这篇关于具有简单数据主义的分页功能。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!