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、后台可以根据字段值判断列中需要显示的图标、数值;

相关推荐
m0_7381207223 分钟前
CTFshow系列——命令执行web38-40
前端·windows·安全·web安全
是小狐狸呀2 小时前
elementUI-表单-下拉框数据选中后,视图不更新
前端·javascript·elementui
四岁半儿4 小时前
常用css
前端·css
你的人类朋友5 小时前
说说git的变基
前端·git·后端
姑苏洛言5 小时前
网页作品惊艳亮相!这个浪浪山小妖怪网站太治愈了!
前端
字节逆旅5 小时前
nvm 安装pnpm的异常解决
前端·npm
Jerry6 小时前
Compose 从 View 系统迁移
前端
GIS之路6 小时前
2025年 两院院士 增选有效候选人名单公布
前端
四岁半儿6 小时前
vue,H5车牌弹框定制键盘包括新能源车牌
前端·vue.js
烛阴6 小时前
告别繁琐的类型注解:TypeScript 类型推断完全指南
前端·javascript·typescript