Click here to Skip to main content
15,041,525 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
<asp:Repeater id="rptowner" OnItemDataBound="bind" runat="server">
        <%# ShowPic(Container.ItemIndex, Convert.ToString(DataBinder.Eval(Container.DataItem, "imgSelf")))%>



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>";

            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;

I want to use if-else condition in repeater
<%# (Container.ItemIndex + 9) % 9 == 0 ? "<tr>" : string.Empty %>
                <asp:Image runat="server" Width="100" Height="100" ID="imgcat" AlternateText="Picture Not Found" ImageUrl='<%# "OwnerPictures/" +  DataBinder.Eval(Container.DataItem, "imgSelf")%>' />
           <%# (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
Updated 14-Aug-13 1:05am
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 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
Miss Maheshwari 14-Aug-13 9:08am
so for third row again I have to take third repeater as its again showing 9 images
Dholakiya Ankit 14-Aug-13 23:10pm
can you pls elaborate your requirement more so i can help you in detail
Miss Maheshwari 16-Aug-13 0:49am
its a very simple requirement but seeming hard to solve this.....exactly wat I a repeater 9 images in first row then in second line/row two images(left and right) with some text in between then again 9 images in third row....all images are coming dynamically from database...
Dholakiya Ankit 16-Aug-13 2:31am
so you can do like this



u have to use nested repeater

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

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

<%# 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"


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