在FormView控件ASP.NET隐藏标签 [英] Hide label in Formview ASP.NET

查看:209
本文介绍了在FormView控件ASP.NET隐藏标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在FormView控件一个禁止字段。如果该字段的值为false我想隐藏标签从和到。

项模板控件:

 < ASP:标签ID =BannedCheckBox=服务器文本='<%#DisplayTruthValue(エ(禁止)的ToString())%>  /> &安培; NBSP;
< ASP:标签ID =BannedFromLabel=服务器文本='<%#来源:+的eval(BannedFrom)%>' />&安培; NBSP;
< ASP:标签ID =BannedToLabel=服务器文本='<%#为:+的eval(BannedTo)%>' />

背后code:

 保护小组FrmViewPatron_DataBound(发送者为对象,E作为EventArgs的)把手FrmViewPatron.DataBound
昏暗blnBan作为字符串= DirectCast(FrmViewPatron.FindControl(BannedCheckBox),标签)。文本
如果blnBan =FALSE然后,万一


解决方案

您已经在数据绑定标签,为什么不设置Visible属性相同的方式。添加可见='<%#(的eval(禁止)==真)%> 这两个标签,或者只是的eval(禁止),如果它是一个布尔字段。

I have a "Banned" field in the formview. If the value of this field in false I want to hide the label "From" and "To".

Item template control:

<asp:Label ID="BannedCheckBox" runat="server" Text='<%# DisplayTruthValue(Eval("Banned").ToString())%>' /> &nbsp;
<asp:Label ID="BannedFromLabel" runat="server" Text='<%# "From: " + Eval("BannedFrom")%>'  />&nbsp;
<asp:Label ID="BannedToLabel" runat="server" Text='<%# "To: " + Eval("BannedTo")%>' />

Code behind:

Protected Sub FrmViewPatron_DataBound(sender As Object, e As EventArgs) Handles FrmViewPatron.DataBound
Dim blnBan As String = DirectCast(FrmViewPatron.FindControl("BannedCheckBox"), Label).Text
If blnBan = "False" Then

End If

解决方案

You are already databinding the label so why not set the Visible property the same way. Add Visible='<%# (Eval("Banned") == "True") %>' to both labels, or just Eval("Banned") if it is a boolean field.

这篇关于在FormView控件ASP.NET隐藏标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆