在C#中的中继器控件中的应用条件 [英] Applying condition in Repeater Control in C#
本文介绍了在C#中的中继器控件中的应用条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在转发器控制中应用条件.
如果数据库表中的字段为null或为空,则不得显示与其关联的标签.
已经尝试过:
I want to apply condition in repeater control.
If the field in database table in null or empty, the label associated with it must not be displayed.
Have tried with this:
<asp:Label ID="Label1" runat="server" Font-Size="X-Large" ForeColor="DeepSkyBlue"
Style="position: static" Text="Search Results" visible="<%# CanIDisplayBeds(DataBinder.Eval(Container.DataItem,"Beds")) %>" ></asp:Label>
其中后面的代码具有以下功能:
where code behind has following function:
protected bool CanIDisplayBeds(Object retBeds)
{
return (retBeds != "");
}
收到错误消息:服务器标签格式不正确."
请帮忙.
我不知道该怎么办.
现在我找到了解决方法.
如下...
Getting error: "Server tag not well formed."
Please help.
I cant make out what to do.
Now I have found out the solution.
It is as below...
推荐答案
嗨....
我有解决方案!!!!
为此,我从后面的代码中删除了该函数,删除了标签,并在aspx页面中添加了以下代码.
其如下.
Hi....
I have got the Solution!!!!!
For this, I have removed the function from code behind, removed the label and just added following code in aspx page.
Its as follows.
<%#(DataBinder.Eval(Container.DataItem,"Beds").ToString()=="")?" ": " Bedroom "%>
现在很开心!!!!!!!!
Am happy now!!!!!
让我们看看此 [ ^ ]文章以了解如何处理在ASP.NET Repeater控件中处理空数据
Tale a look at this[^] article to know how to handle Handling Empty Data in an ASP.NET Repeater control
这篇关于在C#中的中继器控件中的应用条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文