爱的色放
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using CSDN.Share.Controller;
using CSDN.Share.Contract;
using System.Collections.Generic;
namespace WebTest
{
public partial class _Default : System.Web.UI.Page
{
Dictionary res = null;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
//BindData();
Test();
}
private void Test()
{
string content = string.Empty;
content = Reducer.GetShareResourceContent(ResourceType.Music, "2");
Response.Write(content);
}
private void BindData()
{
string userName = this.TextBox1.Text;
ShareItemPagedList list = Reducer.GetUserShareList(1, 5, userName, ResourceType.None);
Reducer r = new Reducer();
r.Process(list.Items);
this.ShareData.DataSource = list.Items;
res = r.Resources;
this.ShareData.DataBind();
}
private string GetContent(int type, string id)
{
string key = string.Format("{0}-{1}", type.ToString(), id.ToString());
if (res != null && res.ContainsKey(key))
{
return res[key];
}
return "资源已被删除!";
}
protected void ShareData_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
ShareItem item = e.Item.DataItem as ShareItem;
Literal l = e.Item.FindControl("Title") as Literal;
l.Text = item.Title;
l = e.Item.FindControl("CreateDate") as Literal;
l.Text = item.CreateDate.ToShortDateString();
l = e.Item.FindControl("Content") as Literal;
l.Text = GetContent((int)item.ResourceType, item.ResourceId);
l = e.Item.FindControl("Description") as Literal;
l.Text = string.Format("“{0}”", item.Description);
}
}
protected void Button1_Click(object sender, EventArgs e)
{
BindData();
}
}
}
发表于 @ 2008年07月31日 22:13:00|评论(loading...)|收藏