频道直达 - 学院 - 下载 - 交易 - 截图 - 特效 - 字库 - 手册 - 排名-工具 - 繁體
设为首页
加入收藏
联系我们
建站搜索: 虚拟主机  域名注册   常用广告代码      用户注册 | 用户登陆
您当前的位置:中国建站之家 -> 网站开发 -> ASP -> 文章内容
精彩推荐
热门文章
· 注册码大全二
· 注册码大全四
· 注册码大全一
· 通过google 赶快来赚..
· [图文] 头像-qq头像(..
· 要10G免费网络硬盘的..
· 注册码大全三
· 注册码大全十
· [图文] 梦幻背景图片..
· [图文] 卡通动物图片..
相关文章
· ASP.net组件编程中的两种..
· 转换十进制为二进制的函..
· PHP中操作MySQL数据库的..
· SQL Server数据库技术(..
· 如何优化广告提高点击率..
· 一个用PHP实现的UBB类!..
· Flash MX2004入门与进阶..
· Microsoft .NET 框架常见..
· 计算2000年01月01日起到..
· 设置 Macromedia Flash ..
使用Repeater模板
作者:未知  来源:转载  发布时间:2005-7-25 21:18:30  发布人:acx

减小字体 增大字体

注)下面的代码是页面的代码,只贴了Repeater部分的代码,因为要绑定数据,如()所以在使用之前要先导入名空间

<asp:repeater id="Repeater1" runat="server">
<HeaderTemplate>
<table?border="0">
<tr?bgcolor="#999999">
<td>产品类型IDtd>
<td>产品类型名称td><td>产品类型描述td>
<td>&nbsp;td>
<tr>
<HeaderTemplate>
<ItemTemplate>
<tr?bgcolor=#ffffff>
<td><img src=".iamgesattachtb.gif">
<td>
<td>
<td>
<td>td>
<td><asp:ImageButton ID="show"ImageUrl=".\iamges\more.gif"
CommandName="show" Runat="server" />td>
<tr>
<ItemTemplate>
<AlternatingItemTemplate>
<tr bgcolor=#f5f2f7>
<td><img src=".iamgesattachtb.gif">

<td>
<td>td>
<td>td>
<td><asp:ImageButton ID="Imagebutton1" ImageUrl=".\iamge\smore.gif"
CommandName="show" Runat="server"/>
<td>
<tr>
AlternatingItemTemplate>
<FooterTemplate>
<table>
<FooterTemplate>
asp:repeater>form>
<body>
<HTML>

后置代码部分:
先导入名空间:using System.Data.SqlClient和using System.Windows.Forms;其余系统默认导入

下面是连接库的代码:

?



private void?ConnecDB()
{
SqlConnection con=new SqlConnection("server=localhost;database=Northwind;Trusted_Connection=Yes;");
SqlDataAdapter da=new SqlDataAdapter("select*from Categories",con);
DataSet ds=new DataSet();
ad.Fill(ds,"Categories");
this.Repeater1.DataSource=ds;
this.Repeater1.DataBind();//绑定到Repeater控件
}

下面这段是Repeater模板中的事件

private void Repeater1_ItemCommand(object sender,System.Web.UI.WebControls.RepeaterCommandEventArgs e)
{
if(e.CommandName=="show")
{
MessageBox.Show("you?click"+e.Item.ItemIndex.ToString()+"row","a

show",MessageBoxButtons.OK,MessageBoxIcon.Information,
MessageBoxDefaultButton.Button1,MessageBoxOptions.DefaultDesktopOnly);
}
else
{
MessageBox.Show("you?click?"+e.Item.ItemIndex.ToString()+"
row","altshow",MessageBoxButtons.OK,MessageBoxIcon.Information,
MessageBoxDefaultButton.Button1,MessageBoxOptions.DefaultDesktopOnly);
}
}
(注:1、必须在Repeater模板事件中绑定上面方法到其ItemCommand事件,在事件窗口中可以做到2、在上面的图片URL应是 ImageUrl=".\iamges\more.gif",由于BLOG对代码的支持有问题,所以被自动截取掉了)

最终效果如下:

[打 印]
[] [返回上一页] [收 藏]
∷相关文章评论∷    (评论内容只代表网友观点,与本站立场无关!) [更多评论...]
关于本站 - 网站帮助 - 广告合作 - 下载声明 - 友情连接 - 网站地图 - 人才招聘
网站合作、内容监督、商务咨询:QQ: 9576619
Copyright ? 2005--2008 中国建站之家版权所有
未经授权禁止转载、摘编、复制或建立镜像.如有违反,追究法律责任.
免责申明:中国建站之家(www.jz123.cn)上的所有提供下载的软件和资源
均来源于网络,为软件或程序作者提供和网友推荐收集整理而来,仅供学习
和研究使用。如有侵犯你的版权,请立即联系我们,本站将在3个工作日内删除。
粤ICP备05092265号