当前位置:编程学习 > C#/ASP.NET >>

如何获取datalist 中的控件???

在list的模板中添加了,一个imageButton的按钮,然后就是单击这个按钮会添加这个人为好友。。。
这个事件是在哪里写 是imagebutton.click里面还是什么的?????和如何获取模板中另外的歌label控件的值?? --------------------编程问答--------------------

//当然在imagebutton.click中写了
//参考:

ImageButton btn= sender as ImageButton ;
DataListItem  item=btn.parent.parent as DataListItem ;
label label1= (label)item.FindControl("label1");
string s=label1.Text; //得到label的值

--------------------编程问答-------------------- ItemCommand事件中编写代码试下,同时给ImageButton指定CommandName --------------------编程问答--------------------
引用 2 楼 wybxs2006 的回复:
ItemCommand事件中编写代码试下,同时给ImageButton指定CommandName

能不能详细点 --------------------编程问答--------------------

<asp:ImageButton runat="server" id="ibtndelete" commandName="del"></asp:ImageButton>



datalist_itemCommand事件里面,通过e.commandName来判断你当前操作的按钮是哪个,并处理时间
--------------------编程问答-------------------- 谢谢已经解决? --------------------编程问答-------------------- 那结贴吧
补充:.NET技术 ,  ASP.NET
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,