请问为什么下面的Button bt_Nice添加不了C#事件 test_click
但是Label可以正常修改,到底怎么添加Repeater的里面的控件事件呢?
//Repeater事件的总项目数
for (int i = 0; i <= Repeater1.Items.Count - 1; i++)
{ //ccs.Click += new EventHandler(click);//加上事件
//this.form1.Controls.Add(ccs); //控件组也加上
a
Button bt_Nice = (Button)Repeater1.Items[i].FindControl("bt_Nice");
this.form1.Controls.Add(bt_Nice);
bt_Nice.Click+=new EventHandler(test_click);//-----这句
Label lb = (Label)Repeater1.Items[i].FindControl("lb");
lb.Text = Convert.ToString((i+1));
}
//事件
protected void test_click(object sender, EventArgs e)
{
Response.Redirect("index.aspx");
}
但是Label可以正常修改,到底怎么添加Repeater的里面的控件事件呢?
//Repeater事件的总项目数
for (int i = 0; i <= Repeater1.Items.Count - 1; i++)
{ //ccs.Click += new EventHandler(click);//加上事件
//this.form1.Controls.Add(ccs); //控件组也加上
a
Button bt_Nice = (Button)Repeater1.Items[i].FindControl("bt_Nice");
this.form1.Controls.Add(bt_Nice);
bt_Nice.Click+=new EventHandler(test_click);//-----这句
Label lb = (Label)Repeater1.Items[i].FindControl("lb");
lb.Text = Convert.ToString((i+1));
}
//事件
protected void test_click(object sender, EventArgs e)
{
Response.Redirect("index.aspx");
}
解决方案 »
- ASP.NET MVC3 添加了一个ASP(C#)视图,之后把他设为起始页,又删除了,想用Global进行设置不管用了
- 像淘宝这样:上架商品到一定时间就可以自动下架 是怎么做的?
- DetailsView1查询的问题
- 这样的数据插入大家时怎么实现的呢
- 当打开IE的时候是个300宽,200长的页面,输入用户名和密码后变成全屏幕的功能怎么实现(WEB)?
- 是什么病毒引起部分文件夹下的文件丢失,但文件夹还在,系统文件丢失后,系统就崩溃?你不知道了不要紧,告诉我一个好的反病毒网站也可
- "Object reference not set to an instance of an object":奇怪的错误
- 各位大哥斑竹帮帮我,如何用datagrid显示的数据限定每栏的字数?并在后面带上…!???
- 请指教奇怪的问题:datagrid中的checkbox删除数据时,一定要选中第一项,否则不能删除。附代码
- GridView中的buttonfield如何设置为非活性
- 回发问题
- 啥是单元测试,有啥作用?
{
RepeaterItem item =(RepeaterItem) ((Button)sender).Parent;
Label l = (Label)item.FindControl("lbl");
Response.Write(l.Text);
}