如何在按钮单击事件的特定条件下将LABEL隐藏在数据列表中 [英] how hide LABEL inside datalist under certain condition on button click event
本文介绍了如何在按钮单击事件的特定条件下将LABEL隐藏在数据列表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好
在按钮单击事件(如
)下的特定条件下,如何在数据列表中隐藏标签?
hi all
what would be the approach to hide a label inside datalist under certain condition on button click event like
if (column_name=='something'){
hide LABEL;
}
column_name也在数据列表中
感谢
column_name is also inside datalist
thanks
推荐答案
步骤:
1.在按钮单击事件方法中,遍历数据列表项
2.使用FindControl
来访问所需的标签
3.根据需要设置可见性.
试试类似的东西:
Steps:
1. In button click event method, loop through datalist items
2. UseFindControl
to get access to the label you need
3. Set the visibility as per your need.
Try something like:
foreach (DataListItem item in myDataList.Items)
{
Label myTempLabel = (Label)item.FindControl("myLabel");
// Do what you need to with this label
myTempLabel.Visible = false;
}
试试吧!
Try!
这篇关于如何在按钮单击事件的特定条件下将LABEL隐藏在数据列表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文