首页 > 编程 > .NET > 正文

Repeater里switch的使用方法

2024-07-10 13:16:47
字体:
来源:转载
供稿:网友

这是ASPX里的代码

复制代码 代码如下:


<asp:Repeater runat="server">
         <ItemTemplate>
          <%#this.info(Eval("id").ToString(), Eval("id").ToString())%>
         </ItemTemplate>
</asp:Repeater>

下面是CS里代码

复制代码 代码如下:


protected void Page_Load(object sender, EventArgs e)
    {   
        .......
    }
protected string info(string id)
    {
        switch (num)
        {
            case "0":
                returnStr = "ID为0";
                break;
            case "1":
                returnStr = "ID为1";
                break;
            case "2":
                returnStr = "ID为2";
                break;
            case "3":
                returnStr = "ID为3";
                break;
            case "4":
                returnStr = "ID为3";
                break;
        }
        return returnStr;
    }

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表