All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
.NET内置对象之Application对象_[Asp.Net教程]
全面理解javascript的caller,callee,call,apply概念_JavaScript技术_编程技术
根据IP获取当地天气预报的实现_[Asp.Net教程]
c#编程中学习数据结构的必要性
使用PHP开发网站过程中你注意到这些安全知识了吗?_[PHP教程]
入门:Windows环境下PHP动态网页配置详解_php资料_编程技术
Windows2003中配置运行ASP.net程序_[Asp.Net教程]
ASP.NET2.0,文本编辑器FCKeditor使用方法详解_[Asp.Net教程]
开发技术展望,Asp.net3.0,蓝图_.net资料_编程技术
XML入门教程:XML是如何被利用的?_[XML教程]
Reading number is top 10 pictures
什么叫国家
男人们都在想什么
遇到插队的怎么办?
人造器官和铁肺人
The money of more than 100 countries and regions10
29 the belle stars after bath figure5
青涩甜美-王祖贤小时候的旧照片曝光
美女
Nikon microscopic photography of the first three
福利福利。。。。。。
Download software ranking
Tram sex maniac 2 (H) rar bag15
Unix video tutorial5
The Bermuda triangle2
美女游泳记
Boxer's Top ten classic battle4
网页特效实例大全
Tram sex maniac 2 (H) rar bag9
Sora aoi, the nurse, uniform ,nursing assistant
美女写真1
网络管理员第三版
delv published in(发表于) 2014/1/24 9:15:44 Edit(编辑)
在DataList中使用用户控件_[Asp.Net教程]

在DataList中使用用户控件_[Asp.Net教程]

在DataList中使用用户控件_[Asp.Net教程]

DataList相对于datagrid对数据的显示要灵活一些(还是在vs2003的叫法).应为DATALIST提供了几个模板,而在模板中可以灵活的放置一些自定义的用户控件。具体实施如下:


先创建用户控件:


<%@ Control Language="C#" AutoEventWireup="true" CodeFile="authorNormal.ascx.cs" Inherits="authorNormal" %>






作者编号:











作者姓名:










后台代码:


private string au_ID;
public string Au_ID
{
set
{
au_ID = value;
}
get
{
return au_ID;
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.bind();
}
}
private void bind()
{
SqlDataReader sdr = new Author().show(this.Au_ID );
while (sdr.Read())
{
this.lblId.Text = sdr["au_id"].ToString();
this.lblName .Text = sdr["au_lname"].ToString().Trim() + " " + sdr["au_fname"].ToString().Trim();
}
}
}


注意:要定义用户控件的一个属性,该属性可以是只写的,用于接收datalist绑定的信息。


前台页面的代码:


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="UserControlInDataList.aspx.cs" Inherits="UserControlInDataList" %>


<%@ Register Src="authorNormal.ascx" TagName="authorNormal" TagPrefix="uc1" %>





无标题页


















Au_ID =<%#DataBinder.Eval(Container.DataItem,"au_id") %>>













后台代码:


protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.DataList1.DataSource = new Author().bind();
this.DataList1.DataBind();
this.DataList1.DataKeyField = "au_id";
}
}


在绑定的页面内容时候,可以使用任何的数据(查询后的,或内存,或从XML文件加载都可以)。


特别要强调的是:如果是根据条件查询后的往往要通过viewstate或session传递,如果传递的数据多,可以将数据先一个arraylist中,然后传递,然后在datalist页面绑定的时候,可以借助于一个虚拟表。

来源:sdtsfhh的blog







添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.