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

Conditions within .aspx file for ListView ItemTemplate

开发者 https://www.devze.com 2023-02-13 01:39 出处:网络
Is there a way to filter <%Eval(\"value\") %> within ASPX file? <ItemTemplate> <tr class=\'<%# Container.DataItemIndex % 2 == 0 ? \"row\" : \"row alt\" %>\'>

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

精彩评论

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