如何根据数据源条件更改中继器控件的可见性? [英] How Do I Change Visibility Of A Repeater Control, Based On Datasource Condition?

查看:89
本文介绍了如何根据数据源条件更改中继器控件的可见性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想设置ASP的可见性:LINKBUTTON基于Repeater DataSource属性的条件TYPE



如果DataItem.Type属性==实际将可见性设置为true,否则为false;



显然数据源中的某些行将为true,有些行将为false,我只想隐藏当前行所有按钮。



我尝试过以下代码:



I am wanting to set the visibility of a ASP:LINKBUTTON based on the condition of the Repeaters DataSource property TYPE

if the DataItem.Type property == "practical" set visibility to true otherwise false;

Obviously some rows in the datasource will be true and some will be false, i only want to to hide the current row not all buttons.

I have tried the below code:

Visible="<%# DataBinder.Eval(Container,"DataItem.Type").ToString().ToLower() == "practical" ? true : false %>"





i还在语音标记中尝试了值true和false,但没有优势:



错误我收到的是:





i have also tried the values true and false in speech marks but to no prevail:

error i recieve is:

Parser Error Message: The server tag is not well formed.

Source Error: 


Line 84:                                     </td>
Line 85:                                     <td width="17%">
Line 86: <asp:LinkButton runat="server" ID="lbAddDates" Visible="<%# DataBinder.Eval(Container,"DataItem.Type").ToString().ToLower() == "practical" ? "true" : "false" %>" CommandName="AddDates" OnCommand="lbCourseActionItems_Click" CommandArgument='<%# DataBinder.Eval(Container, "DataItem.Id").ToString() + "," + DataBinder.Eval(Container, "DataItem.IsActive").ToString() + "," + DataBinder.Eval(Container, "DataItem.Title").ToString()  %>' class="button">
</asp:LinkButton>





任何有关此问题的帮助将不胜感激。



Any help on this would be greatly appreciated.

推荐答案

您的服务器标签包含引号。使用单引号作为外部引号以获得格式良好的标记。

Your server tag includes quotes. Use single quotes as outer quotes to get a wellformed tag.
Visible='<%# DataBinder.Eval(Container,"DataItem.Type").ToString().ToLower() == "practical" ? true : false %>'


这篇关于如何根据数据源条件更改中继器控件的可见性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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