首页 新闻 会员 周边

请问在asp.net中如何插入分页图片,就像空间相册一样,全是图片,还要分页

0
[待解决问题]

asp
段呱呱的主页 段呱呱 | 初学一级 | 园豆:200
提问于:2011-12-25 13:10
< >
分享
所有回答(3)
0

只要你会上传图片就可以了啊,分页只是读取时处理一下就可以了

artwl | 园豆:16736 (专家六级) | 2011-12-25 16:15
0

就是正常的数据分页啊,跟新闻列表一样,你认为是怎样的?

三桂 | 园豆:3565 (老鸟四级) | 2011-12-26 15:58
0

图片用一个列表显示,插入图片,就按正常程序走,将图片转换成二进制或者只是将图片放置到服务器,然后把地址保存到数据库中,然后用一个dataList 将图片显示出来就可以了啊,简单的例子:

<asp:DataList runat="server" RepeatDirection="Horizontal" RepeatColumns="4">
<itemtemplate>
<table cellspacing="16" cellpadding="1" width="150px" border="0" runat="server">
<tr>
<td align="center">
<font face="宋体">
<asp:HyperLink runat="server" NavigateUrl='<%# "ProductDetail.aspx?ffollower_id").ToString() %>'><asp:Image runat="server" Width="150" Height="160" ImageUrl='<%# GetPath() + Eval("follower_url").ToString() %>'>
</asp:Image></asp:HyperLink></font>
</td>
</tr>
<tr>
<td align="center">
<font face="宋体">
<asp:Label runat="server" Width="112px" Height="20px" Text='<%# Eval("follower_name").ToString() %>'>
</asp:Label></font>
</td>
</tr>
<tr>
<td align="center">
<font face="宋体">¥:
<asp:Label runat="server" Width="63px" Height="16px" Text='<%# Eval("member_price").ToString() %>'>
</asp:Label></font>
</td>
</tr>
</table>
</itemtemplate>
</asp:DataList>

你可以在后台设置下dataList 就可以了,然后显示的效果就会带有分页的

JasonNET | 园豆:168 (初学一级) | 2011-12-26 16:29

是的,就是这种方法,可是我是初学者,什么都不懂,可以详细点么?

支持(0) 反对(0) 段呱呱 | 园豆:200 (初学一级) | 2011-12-26 16:45

@段呱呱: 我把代码给你看下吧 

前台代码:

View Code
<%@ Register TagName="top" TagPrefix="uc1" Src="~/top.ascx" %>
<%@ Register TagName="left" TagPrefix="uc2" Src="~/left.ascx" %>
<%@ Register TagName="bottom" TagPrefix="uc3" Src="~/bottom.ascx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2">
<uc1:top ID="top" runat="server" />
</td>
</tr>
<tr>
<td align="left" valign="top" style="width:20%">
<uc2:left ID="left" runat="server" />
</td>
<td>
<asp:DataList ID="DataList1" runat="server" style="display:inline; margin-top:-600px; margin-left:230px; position:absolute;" RepeatDirection="Horizontal" RepeatColumns="4">
<itemtemplate>
<table id="Table8" cellspacing="16" cellpadding="1" width="150px" border="0" runat="server">
<tr>
<td style="height: 28px" align="center">
<font face="宋体">
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# "ProductDetail.aspx?fid="+Eval("follower_id").ToString() %>'><asp:Image ID="Image1" runat="server" Width="150" Height="160" ImageUrl='<%# GetPath() + Eval("follower_url").ToString() %>'>
</asp:Image></asp:HyperLink></font>
</td>
</tr>
<tr>
<td align="center">
<font face="宋体">
<asp:Label ID="Label1" runat="server" Width="112px" Height="20px" Text='<%# Eval("follower_name").ToString() %>'>
</asp:Label></font>
</td>
</tr>
<tr>
<td align="center">
<font face="宋体">¥:
<asp:Label ID="Label2" runat="server" Width="63px" Height="16px" Text='<%# Eval("member_price").ToString() %>'>
</asp:Label></font>
</td>
</tr>
</table>
</itemtemplate>
</asp:DataList>
<asp:Label runat="server" ID="lbl_msg" Text="Label"></asp:Label>
</td>
</tr>
<%--<tr>
<td colspan="2">
<uc3:bottom ID="bottom" runat="server" />
</td>
</tr>--%>
</table>
</form>
</body>
</html>

后台代码:

View Code
using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class Product1 : System.Web.UI.Page
{
FollowerBLL.Followers f_bll = new FollowerBLL.Followers();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
lbl_msg.Visible = false;
BindFollowerList();
}
}

///<summary>
/// 默认绑定产品列表
///</summary>
private void BindFollowerList()
{
DataSet ds = f_bll.GetAllList();
if (ds.Tables != null && ds.Tables[0].Rows.Count > 0)
{
DataList1.DataSource = ds;
DataList1.DataBind();
}
else
{
lbl_msg.Visible = true;
lbl_msg.Text = "暂无相关信息!";
}
}

protected string GetPath()
{
string serverPath = "~" + System.Configuration.ConfigurationManager.AppSettings["ImgPath"];
string path = Server.MapPath(serverPath + "/");
return path;
}
}

方法很简单的,自己写Sql语句将数据查询出来就好了,DataList中你绑定的字段要跟Sql语句中出现的字段保持一致。我这个代码中的Sql语句是在Dal层中写的,所以这里不会出现。呵呵

所以我觉得你看下应该能明白,实在不行,你拷贝下来然后改改方法也行 呵呵


支持(0) 反对(0) JasonNET | 园豆:168 (初学一级) | 2011-12-27 09:49
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册