within ASPX file? <ItemTemplate> <tr class=\'<%# Container.DataItemIndex % 2 == 0 ? \"row\" : \"row alt\" %>\'>" />
开发者

Conditions within .aspx file for ListView ItemTemplate

Is there a way to filter <%Eval("value") %> within ASPX file?

 <ItemTemplate>
     <tr class='<%# Container.DataItemIndex % 2 == 0 ? "row" : "row alt" %>'>
        <td c开发者_JAVA技巧lass="width-200"><%#Eval("znacka") %></td>
        <td class="width-200"><%#Eval("status") %></td>
        <td><asp:LinkButton ID="btnZnackyDelete" runat="server" Text="delete" CommandName="Delete" /></td>
     </tr>
 </ItemTemplate>

I want to show linkbutton only if Eval("status") == 0

is it possible within aspx file? Or how do you specify this within c# code?


This should work:

<asp:LinkButton ID="btnZnackyDelete" Visible='<%# Convert.ToBoolean(Eval("status").ToString() == "0") %>' runat="server" Text="delete" CommandName="Delete" />


Use an if statement, that's easiest.

<% if (Eval("value") == 0) { %>
<asp:LinkButton ID="btnZnackyDelete" runat="server" Text="delete" CommandName="Delete" />
<% } %>

You can also handle the OnItemDataBound event for the repeater or whatever you are using. In that you can use findcontrol and toggle visibility.

If is by far easier though.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜