要分页此代码. [英] want to paging in this code.

查看:77
本文介绍了要分页此代码.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是下面wann给出的添加分页代码的代码,给我一个代码.图像需要太多时间才能打开我的工作?

This is the code given below wann to add paging pls give me a code.Images take too much time to open what i do ?

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;

public partial class dsoftphoto : System.Web.UI.Page
{
// string m_lastFileName = "none";

protected void Page_Load(object sender, EventArgs e)
 {
    Image img;

    if (!IsPostBack)
    {
        DirectoryInfo di = new DirectoryInfo(Server.MapPath("~/images"));
        int row=0;
        int col = 0;
        Table tb = new Table();
        TableRow tr = new TableRow();


    foreach (FileInfo fi in di.GetFiles())
    {
        img = new Image();
        if (row == 0)
        {
            tr = new TableRow();
            img.ID = "ImageButton" + row;
            row++;
        }
        else
        {
            row++;
            if (row == 6)
            {
                row = 0;
                col++;
                if (col == 1)
                {

                }
            }
        }
        Panel pan = new Panel();
        pan.Height = 84;
        pan.Width = 110;


     	img.ImageUrl = "../images/" + fi.Name;
	img.Height = 84;
	img.Width = 87;
	img.Attributes.Add("onclick", "javascript:window.open('" + "images/" + fi.Name + "');return false;");
	Table t1 = new Table();
	TableRow t2 = new TableRow();
	TableCell t3 = new TableCell();

	t1.ControlStyle.Width = 50;
	t1.ControlStyle.BorderWidth = 1;
	t1.ControlStyle.BorderColor = System.Drawing.Color.FromName("#148CC7");

	t3.Controls.Add(img);
	t2.Cells.Add(t3);
	t1.Controls.Add(t2);
        t1.Rows.Add(t2);
	pan.Controls.Add(t1);

	TableCell tc = new TableCell();

	tc.Controls.Add(pan);
	tr.Cells.Add(tc);

	tb.Controls.Add(tr);
	tb.Rows.Add(tr);
	Panel1.Controls.Add(tb);
	PlaceHolder1.Controls.Add(tb);

      }
    }
  }
}

推荐答案

首先,鉴于您正在显示较小尺寸的图像,因此将副本保留在缩略图目录中,这样您就不必加载完整的图像即可显示较小的版本.然后,如果需要,我将创建一个数据库,该数据库存储图像的路径以及要显示的名称等.然后,我将使用gridview并使用控件中内置的分页以分页格式显示缩略图.如果所需的布局不适用于Gridview,则可以使用中继器,但是我认为您需要自己进行分页.在这种情况下,请执行一个SQL调用以找出页面数,以呈现页面控制,然后执行另一个SQL请求以仅请求当前页面上的数据.
First of all, given that you''re showing images in a smaller size, I''d keep a copy in a thumbnails directory, so that you don''t have to load the full images in order to show a smaller version. Then I''d create a database which stores the paths to the images, as well as a name to show, etc, if desired. Then I''d use a gridview and use the paging built into the control to show the thumbnails in a paged format. If the layout you want doesn''t work with a gridview, I''d use a repeater, but then I believe you''ll need to do your own paging. In this case, do one SQL call to find out hte number of pages, to render the paging control, and another to request just the data on the current page.


这篇关于要分页此代码.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆