Click here to Skip to main content
15,881,424 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
plz someone tell how to do it
I used the below function but its not working
C#
<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
I want to use if-else condition in repeater
C#
<%# (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 %>

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
Posted
Updated 14-Aug-13 1:05am
v4
Comments
ridoy 13-Aug-13 8:40am    
is it C# or VB?
Miss Maheshwari 14-Aug-13 7:51am    
its c#
Dholakiya Ankit 14-Aug-13 8:08am    
instead all this try alternateitemtemplate inbuilt functionality of repeater where you can do alternate things
Miss Maheshwari 14-Aug-13 8:12am    
I tried but no use
in itemtemplate I want to show 9 images n in alternate itemtemplate I want to show only three images....so how can it possible
Dholakiya Ankit 14-Aug-13 8:25am    
you can take two repeater also in one bind 9 and in second bind 3 instead of doing this clumsy tasks

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

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

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


in html
XML
<script runat="server">

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

</script>
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900