1、绑定Repeater 基础用法

   <%#Eval("RoleID")%>

2、简单判断用法

<td>
<%# Convert.ToBoolean(Eval("UserIsSupperPower")) ? "<span id='spIsSupperman' style='color:green'>" + superman + "</span>" : no%>
</td>

3、较复杂用法

   <a  href="EditUser.aspx?action=edit&id=<%# Eval("UserID")%>&t=' + new Date().getTime()';" ><span class='am-icon-pencil-square-o'></span><%=edit %></a> &nbsp;

4、复杂用法,用一个后台方法,封装,前台输出

   <%# IsDisplayItem(Eval("RoleDescription"),Eval("RoleID")) %>

后台代码

/// <summary>
        /// 根据角色描述 判断是否为移动端角色项,如是则隐藏编辑项
        /// </summary>
        /// <param name="roleDesc"></param>
        /// <param name="roleId"></param>
        /// <returns></returns>
        public string IsDisplayItem(object roleDesc,object roleId) 
        {
            string strResult = "";
            if (!roleDesc.ToString().Contains("移动"))
            {
                strResult = "<a href='EditRole.aspx?Action=Edit&RoleId=" + roleId + "&t=' + new Date().getTime());" + "><span class='am-icon-pencil-square-o'></span>";
                strResult += edit + "</a> &nbsp;&nbsp";
                strResult += "<a href='?action=delete&RoleId=" + roleId + " style='color:#dd514c;' onclick='return confirm($('#hidAlertDelete.ClientID').val());'>";
                strResult += " <span class='am-icon-trash-o'></span>" + delete + "</a>";
            }
             return strResult;
        }

5、拓展下<% if%>用法

<%if(true)%>
<%{%>
<asp:TextBox >
<OPTION selected></OPTION>
</SELECT>
<%}%>

相关文章:

  • 2021-12-06
  • 2021-04-17
  • 2021-08-17
  • 2022-01-03
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-10
  • 2021-06-20
  • 2022-01-24
  • 2022-02-07
相关资源
相似解决方案