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

相关推荐
tHeya06II7 分钟前
.NET AI 核心构建块:重塑智能应用开发的架构范式与生态
人工智能·架构·.net
TON_G-T32 分钟前
useEffect为什么会触发死循环
java·服务器·前端
Aurorar0rua38 分钟前
CS50 x 2024 Notes C - 02
前端
海参崴-1 小时前
C++代码格式规范
java·前端·c++
wd5i8kA8i1 小时前
.NET 10 New feature 新增功能介绍-Minimal APIs增强
.net
谢尔登1 小时前
【React】setState 触发渲染的流程
前端·react.js·前端框架
摸鱼仙人~2 小时前
Vue中markdown-it基础使用教程
前端·javascript·vue.js
落魄江湖行2 小时前
入门篇二:Nuxt 4路由自动生成:告别手动配置路由的日子
前端·vue.js·typescript·nuxt4
UAq6wn76j2 小时前
.NET源码生成器使用SyntaxTree生成代码及简化语法
java·开发语言·.net
CQU_JIAKE3 小时前
4.4【Q】
java·前端·javascript