1.取repeater控件里的一项的控件。
如我在repeater控件的项模板中加了一个panel,想动态控制他的可显示。这么写:
Repeater rp = this.Reapter1;//找出Repeater控件出来是第一步
rp.DataSource = this.dtDefault;//此处必需得再连一次
rp.DataBind();
int coun = rp.Items.Count;//得到Repeater的项数
for (int i = 0; i < coun; i++)//循环所有项
{
Panel pman = (Panel)rp.Items[i].FindControl("pMan");//通过控件名找到控件
pman.Visible = true;
}
2.repeater控件里的按钮事件。
现在标签中设好CommandName的值.
然后事件处理程序
protected void Reapter1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if (e.CommandName == "btnRep")
{
object ee;
ee=e.Item.DataItem;
}
}