if if条件在转发器 [英] if else condition in repeater

查看:114
本文介绍了if if条件在转发器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

plz有人告诉我该怎么做

我使用了以下功能,但它不起作用

plz someone tell how to do it
I used the below function but its not working

<asp:Repeater id="rptowner" OnItemDataBound="bind" runat="server">
&lt;HeaderTemplate>
<table>
&lt;/HeaderTemplate>
        <ItemTemplate>
        <%# ShowPic(Container.ItemIndex, Convert.ToString(DataBinder.Eval(Container.DataItem, "imgSelf")))%>

            </ItemTemplate>

        <FooterTemplate></table></FooterTemplate>
    </asp:Repeater>


protected string ShowPic(int num, string path)
    {
        code = "";
        if (num == 0)
        {
            code = "<tr>";
            code += " <td><asp:Image runat='server' Width='100' Height='100' alt='Picture Not Found' ID='ctl00_rptowner_ctl0"+(num+1)+"_imgcat' ImageUrl='OwnerPictures/" + path + "' /></td>";

        }
        else if (num >= 1 && num <= 7)
        {
            code = " <td><asp:Image runat='server' Width='100' Height='100' alt='Picture Not Found' ID=ctl00_rptowner_ctl0" + (num + 1) + "_imgcat' ImageUrl='OwnerPictures/" + path + "' /></td>";

        }
        else
            if (num == 8)
            {
                code = " <td><asp:Image runat='server' Width='100' alt='Picture Not Found' Height='100' ID=ctl00_rptowner_ctl0" + (num + 1) + "_imgcat' ImageUrl='OwnerPictures/" + path + "' /></td>";
                code += "</tr>";
            }

        return code;
    }







hello

我想用,如果转发器中的条件




hello
I want to use if-else condition in repeater

<%# (Container.ItemIndex + 9) % 9 == 0 ? "<tr>" : string.Empty %>
               <td>
                <asp:Image runat="server" Width="100" Height="100" ID="imgcat" AlternateText="Picture Not Found" ImageUrl='<%# "OwnerPictures/" +  DataBinder.Eval(Container.DataItem, "imgSelf")%>' />
                </td>
           <%# (Container.ItemIndex + 9) % 9 == 8 ? "</tr>" : string.Empty %>



它将连续显示9张图片

现在在第二行/备用行中我想显示两个图像(左边1个,右边1个),中间有一个文本,所以我需要在转发器中使用if-else

任何人都可以帮助


it will display 9 images in a row
now in second/alternate row I want to display two images(1 in left & 1 in right) and one text in between so I need to use if-else in repeater
can anyone plz help

推荐答案

探索这些..

如果在转发器中声明 [ ^ ]

如何在转发器内执行if语句 [ ^ ]

C#转发器中的条件h [ ^ ]
Explore these..
If statement in repeater[^]
How can i do an if statement inside a repeater[^]
condition in C# repeater h[^]


如果项目在multitime中重复并且调用函数项重复为值



if item repeated in multitime and call function item repeated as the values

<asp:Repeater ID="Repeater5" runat="server" OnItemCommand="rpt_ItemsallerCommand">
                  <ItemTemplate



<%#FunctionName(Convert.ToString(DataBinder.Eval(Container.DataItem,discPrice)))%>





in html


<%# FunctionName(Convert.ToString(DataBinder.Eval(Container.DataItem, "discPrice")))%>


in html

<script runat="server">

 protected  string FunctionName (string theValue) {
       if(theValue == "SAVED") {
     return "theValue";
        } else {
return "theValue"
       }
    }

</script>


这篇关于if if条件在转发器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆