ADO.Net前端页面调用后台方法使用

1、前台页面定义GetSource方法,传入列表显示字段;

cs 复制代码
<asp:Repeater ID="rptList" runat="server">
    <ItemTemplate>
        <tr class="lsi-t">
            <td>
                <%# Container.ItemIndex+1 %>
            </td>
            <td>
                  <%# GetSource(Eval("source").ToString())%>
             </td>
        </tr>
    </ItemTemplate>
</asp:Repeater>

2、后台页面定义Public公共类型的方法GetSource;

cs 复制代码
public string GetSource(string source)
{
    string sourcename = "";
    if(source=="1")//1 = 网页;
    {
        sourcename = "<img title=\"" + Resources.lang.WebPage+ "\" src=\"../img/wangye.png\" style=\"width:20px;height:22px;margin-top:2px;\" />";
    }
    if (source == "2")//2 = APP;
    {
        sourcename = "<img title=\"" + Resources.lang.APP + "\" src=\"../img/APP.png\" style=\"width:20px;height:22px;margin-top:2px;\" />";
    }
    if (source == "3")//3 = 微信小程序;
    {
        sourcename = "<img title=\"" + Resources.lang.WeChatMini + "\" src=\"../img/xiaochengxu.png\" style=\"width:20px;height:22px;margin-top:2px;\" />";
    }
    if (source == "4")//4 = 公众号;
    {
        sourcename = "<img title=\"" + Resources.lang.OfficialAccounts + "\" src=\"../img/gongzhonghao.png\" style=\"width:20px;height:22px;margin-top:2px;\" />";
    }
    if (source == "5")//5 = 对外接口;
    {
        sourcename = "<img title=\"" + Resources.lang.ExternalInterface + "\" src=\"../img/duiwaijiekou.png\" style=\"width:20px;height:22px;margin-top:4px;\" />";
    }
    return sourcename;
}

3、后台可以根据字段值判断列中需要显示的图标、数值;

相关推荐
非优秀程序员5 小时前
第10章 千团出世|《互联网产品恩仇录》
前端
非优秀程序员5 小时前
第11章 小高在对面|《互联网产品恩仇录》
前端
非优秀程序员5 小时前
第14章 只剩美团|《互联网产品恩仇录》
前端
非优秀程序员5 小时前
第09章 老乡何必为难老乡|《互联网产品恩仇录》
前端
非优秀程序员5 小时前
第03章 三大门户,烽烟起于瀛海威|《互联网产品恩仇录》
前端
曦樂~9 小时前
【Web Development】02 CSS
前端·css
风骏时光牛马9 小时前
后端服务接口开发与数据逻辑处理
前端
东鹏特饮9 小时前
经典打砖块(Breakout)游戏
前端·css·css3
IT_陈寒9 小时前
Vite的HMR把我整不会了:一个生产环境的热更新坑
前端·人工智能·后端
Mh10 小时前
如何使用双缓冲优化视频切换
前端