分享下自己的学习成果......
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ListViewOne.aspx.cs" Inherits="ListViewOne" %>
ListView using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class ListViewOne : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(Request.QueryString["ajaxRequest"]))
{
Response.Clear();
PersonInfo person = new PersonInfo().GetData().Where(p => p.ID == int.Parse(Request.QueryString["val"])).First();
if (person != null)
Response.Write(person.Description);
else
Response.Write("not found!!!");
Response.End();
}
if (IsPostBack) return;
lvPersons.DataSource = new PersonInfo().GetData();
lvPersons.DataBind();
}
}
class PersonInfo
{
public int ID { get; set; }
public string Name { get; set; }
public string Sex { get; set; }
public string Description { get; set; }
public List
GetData()
{
return new List()
{
new PersonInfo(){ID=1,Name="张三",Sex="男",Description="aa"},
new PersonInfo(){ID=2,Name="李四",Sex="男",Description="bb"},
new PersonInfo(){ID=3,Name="王八",Sex="男",Description="cc"},
new PersonInfo(){ID=4,Name="张三",Sex="男",Description="dd"},
new PersonInfo(){ID=5,Name="李四",Sex="男",Description="ee"},
new PersonInfo(){ID=6,Name="王八",Sex="男",Description="ff"},
new PersonInfo(){ID=7,Name="张三",Sex="男",Description="gg"},
new PersonInfo(){ID=8,Name="李四",Sex="男",Description="yy"},
new PersonInfo(){ID=9,Name="王八",Sex="男",Description="xx"},
new PersonInfo(){ID=10,Name="张三",Sex="男",Description="ss"},
new PersonInfo(){ID=11,Name="李四",Sex="男",Description="rr"},
new PersonInfo(){ID=12,Name="王八",Sex="男",Description="tt"},
new PersonInfo(){ID=13,Name="张三",Sex="男",Description="uu"},
new PersonInfo(){ID=14,Name="李四",Sex="男",Description="ii"},
new PersonInfo(){ID=15,Name="王八",Sex="男",Description="oo"},
new PersonInfo(){ID=16,Name="张三",Sex="男",Description="pp"},
new PersonInfo(){ID=17,Name="李四",Sex="男",Description=";;"},
new PersonInfo(){ID=18,Name="王八",Sex="男",Description="ll"},
new PersonInfo(){ID=19,Name="张三",Sex="男",Description="aa"},
new PersonInfo(){ID=20,Name="李四",Sex="男",Description="aa"},
new PersonInfo(){ID=21,Name="王八",Sex="男",Description="aa"},
new PersonInfo(){ID=22,Name="张三",Sex="男",Description="aa"},
new PersonInfo(){ID=23,Name="李四",Sex="男",Description="aa"},
new PersonInfo(){ID=24,Name="张三",Sex="男",Description="aa"},
new PersonInfo(){ID=25,Name="李四",Sex="男",Description="aa"},
new PersonInfo(){ID=26,Name="翠花",Sex="女",Description="aa....."},
};
}
}