如果值为 NULL,如何隐藏数据列表中的项目 (asp.net)(visual basic)
例如,在我的数据列表中 if Eval("OptionJ").Tostring = Null 我希望函数 GetVisible 将单选按钮的可见性设置为 false,如下所示:
<input name="Q<%#Eval("ID")%>" type="radio" value="J" visible="<%# GetVisible(Eval("OptionJ").ToString()) %>">
<%#Server.HtmlEncode(Eval("OptionJ").ToString())%>
</option><br />
然后我有一个代码隐藏函数,如下所示:
Protected Function GetVisible(ByVal Evalresult As String) As String
If Evalresult = Nothing Then
Return "False"
Else
Return "True"
End If
End Function
我还尝试检查 EvalResult = String.empty
在输出的html中,可见状态被设置为false...
<input name="Q3" type="radio" value="J" visible="False">
但它仍然显示在页面上!
请让我知道如何让它发挥作用吗?预先感谢您花时间阅读并发布任何答案。
For example in my datalist if Eval("OptionJ").Tostring = Null I would like the function GetVisible to set visibility of the radio button to false like so:
<input name="Q<%#Eval("ID")%>" type="radio" value="J" visible="<%# GetVisible(Eval("OptionJ").ToString()) %>">
<%#Server.HtmlEncode(Eval("OptionJ").ToString())%>
</option><br />
I then have a codebehind function like so:
Protected Function GetVisible(ByVal Evalresult As String) As String
If Evalresult = Nothing Then
Return "False"
Else
Return "True"
End If
End Function
I have also tried checking EvalResult = String.empty
In the outputted html the visible status is being set to false...
<input name="Q3" type="radio" value="J" visible="False">
But it is still displayed on the page!
Please can you let me know how to get this working? Thanks in advance for your time reading and any answers posted.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个:
Visible 属性仅适用于 ASP.NET Server 控件,但这里您使用的是 Html 输入控件。
因此,一种方法是,如果您想继续使用可见属性,请在此控件中添加 runat="server" 属性,第二种方法是为 HTML 输入控件添加 style="visibility:hidden" 属性,如下所示:
Try this one:
Visible property works only for ASP.NET Server control but here you are using Html Input Control.
So one approach is that add runat="server" attribute in this control to if you want to continue with visible property and second one is that add style="visibility:hidden" attribute for HTML input control as given below: