c# - if statement whit DataBinder.Eval -


the code :

<asp:repeater id="repeater2" runat="server">   <headertemplate>     <table cellspacing="0" cellpadding="0" border="0" width="100%">   </headertemplate>   <itemtemplate>     <tr>     <td colspan="3" style="height: 1px; width: 100%; " align="center">     <div style="height: 1px; width: 90%; background-color: #cccccc;"></div>     </td>     </tr>        <% if (databinder.eval(container.dataitem, "productid").tostring() == "32668" || databinder.eval(container.dataitem, "productid").tostring() == "33829" || databinder.eval(container.dataitem, "productid").tostring() == "33831")           { %>      <tr>       <td style="height: 132px; width: 25%; padding-left:20px;"><a href='product_detail_<%# databinder.eval(container.dataitem, "productid")%>.aspx'> <img src='<%= system.configuration.configurationmanager.appsettings["productimageurl"] %>t_<%# databinder.eval(container.dataitem, "productimg")%>'                                         border="0" /></a> </td>       <td align="left" valign="top"><br>         <a href='product_detail_<%# databinder.eval(container.dataitem, "productid")%>.aspx'> <font color="#000000"><b> <%# databinder.eval(container.dataitem, "productname")%> </b></font></a> <br />         <br />         <span class="detailspan"> <%# databinder.eval(container.dataitem, "shortdesc")%> </span></td>       <td style="width: 15%;" align="center"><b> <%# webdirectbrands.utility.formatnumber(convert.todecimal(databinder.eval(container.dataitem, "productprice")))%> </b> <br />         <br />         <a href='product_detail_<%# databinder.eval(container.dataitem, "productid")%>.aspx'> <img src="images/details-link.gif" border="0" /></a> <br />         <a href='add_to_cart.aspx?productid=<%# databinder.eval(container.dataitem, "productid")%>'> <img src="images/addtocart-link.gif" border="0" style="margin-top: 5px;" /></a> </td>     </tr>       <% } %>     <tr>       <td colspan="3" height="15px"></td>     </tr>   </itemtemplate>   <footertemplate>     </table>   </footertemplate> </asp:repeater> 

so have 40 items ,and want show 3 in featured products,i wanted use if statement , operator || problem databinder.eval .i did't find answer can me .can me ? there shorter solution whit "short if "(a == c ? b : c) or solution whitout asp:repeater :) thank in advance.

filtering data before binding repeater optimal solution. subscribe itemdatabound event , decide hide or display particular item on fly.

see link on msdn

in event handler can

e.item.visible = false; 

Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -