repeat 的两个事件ItemDataBound和ItemCommand
来源:互联网 发布:aicc软件免费下载 编辑:程序博客网 时间:2024/05/01 23:39
ItemDataBound主要是用来最后改变一次repeat在客户端加载的数据主要用来设置 ItemCommand主要是利用repeat的按钮控件的CommandName和CommandArgument
1.ItemCommand实例
protected void Repeater3_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if (e.CommandName == "启用")//CommandName主要使前台代码和后台代码打交道
{
T_UsersTableAdapter adapter = new T_UsersTableAdapter();
long id= Convert.ToInt64(e.CommandArgument);//CommandArgument主要使后台与数据库打交道
adapter.AlterjiyongById(id);
Repeater3.DataBind();
}
else if (e.CommandName == "禁用")
{
T_UsersTableAdapter adapter = new T_UsersTableAdapter();
long id = Convert.ToInt64(e.CommandArgument);
adapter.AlterqiyongByID(id);
Repeater3.DataBind();
}
else {
throw new Exception("有错");
}
}
2. ItemDataBound实例
protected void Repeater3_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)//指触发对象的类型是DadaList里的基本行或是替换行(简单的说是Repeater里的所有数据项内容)
{
DataRowView drv = (DataRowView)e.Item.DataItem;
var row = (WebApplication1.ObjDateScr.DAL.DataSetPerson.T_UsersRow)drv.Row;
if (row.state == "禁用")
{
HtmlTableRow trRow = (HtmlTableRow)e.Item.FindControl("trRow");
trRow.Attributes["class"] = "trRow";//给<tr runat="server" class="trRow">的行添加属性
Button btn = (Button)e.Item.FindControl("disable");
btn.Visible = false;
Button btn2 = (Button)e.Item.FindControl("able");
btn2.Visible = true;
}
else if (row.state == "启用")
{
HtmlTableRow trRow = (HtmlTableRow)e.Item.FindControl("trRow");
trRow.Attributes["class"] = "";
Button btn = (Button)e.Item.FindControl("disable");
btn.Visible = true;
Button btn2 = (Button)e.Item.FindControl("able");
btn2.Visible = false;
}
else
{
throw new Exception("非法的状态");
}
}
}
- repeat 的两个事件ItemDataBound和ItemCommand
- Repeater数据控件的两个重要事件ItemDataBound 和 ItemCommand
- ItemCommand,ItemDataBound事件中获取已绑定行的字段的值和服务器端控件
- Grid事件解析与有关ItemCreated和ItemDataBound与ItemCommand的理解
- [Repeater]三個事件的執行先後?ItemDataBound / ItemCreated / ItemCommand
- 有关ItemCreated和ItemDataBound与ItemCommand的理解(1)
- 有关ItemCreated和ItemDataBound与ItemCommand的理解
- 有关ItemCreated和ItemDataBound与ItemCommand的理解
- ItemCreated && ItemDataBound && ItemCommand
- DataGrid的ItemCreated和ItemDataBound事件
- ItemCreated和ItemDataBound事件的区别
- GridView的RowCommand事件和DataList的ItemCommand事件
- GridView的RowCommand事件和DataList的ItemCommand事件
- DataGrid的ItemDataBound事件
- DataGrid的ItemDataBound事件
- DataGrid的ItemDataBound事件
- Repeater 控件的 ItemCommand 事件
- repeat循环绑定ItemDataBound
- pthread_mutex_lock的实现!!
- linux ubuntu 挂载 卸载 u盘
- dataset.xsd的定义(vs2008)
- php 插入中文的问题[转]
- Fedora 10 常用工具安装
- repeat 的两个事件ItemDataBound和ItemCommand
- [转载]ModelSim,synplify,ISE后仿真流程
- 在Apple Mac OS X 10.6.7环境下安装WebLogic 11gR1(10.3.3)
- VS2008+FLTK+X64平台的配置方法
- 如何编译源代码
- Linux解压tar命令
- QQ2011 Beta3优先体验(附官方体验地址及下载地址)
- 使用Delphi快速开发ActiveX控件
- dephi7开发ocx