Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6903739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:57:47+00:00 2026-05-27T07:57:47+00:00

I am trying to make my first public .net website but I have a

  • 0

I am trying to make my first public .net website but I have a little problem.
It’s a webshop, where i want to show at new product picture, if the product is not older than the current date with more than 30 days?

Markup:

 <asp:Repeater ID="rptProducts" runat="server">        
        <ItemTemplate>
            <table cellpadding="5" cellspacing="5" class="tblSales">
                <tr>
                    <td>
                        <h3>
                            <asp:Label ID="Label1" Text='<%#Eval("ProductName")%>' runat="server" /></h3>
                        <h2>
              <a  href='<%# "Products.aspx?ID=" + Eval("ProductID") %>'>Read More</a></h2>
                    </td>
                    <td >
                        <h4>
                            <asp:Label ID="Label2" Text='<%#Eval("ProductPrice")%>' runat="server" />,-</h4>      
                            <div> 
<img alt="New product" src="images/NewProduct.png" /><!--This picture should show in 30 days-->
                              </div> 
                    </td>
                </tr>
                <hr />
            </table>
        </ItemTemplate>
</asp:Repeater>

Code-behind:

public partial class sale : System.Web.UI.Page
{
    ProductsTableAdapter p = new ProductsTableAdapter();

    protected void Page_Load(object sender, EventArgs e)
    {
        GetData();
    }

    protected void GetData()
    {
        rptProducts = p.GetProductsByCategoryID(3);
        rptProducts();        
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T07:57:48+00:00Added an answer on May 27, 2026 at 7:57 am

    EDITED: As a user noted this may be a misinterpretation so…

    IF you want to filter items that were added and not display them at all use the following LINQ expression on the GetData method:

    rptProducts = p.GetProductsByCategoryID(3).Where(p=>p.ProductAddedDate > DateTime.Now.AddDays(-30));
    

    you need to have a property (in the above example I added a DateTime ProductAddedDate to the product class

    IF you want to not show the image based on the date BUT show everything else you could:

    In the ItemDataBound event of the repeater you can set asp control (replace static html with asp:Image which allows you to control display using the Visible property i.e.

    <asp:Repeater ID="rptProducts" runat="server" OnItemDataBound="rptProducts_Databound">        
            <ItemTemplate>
                <table cellpadding="5" cellspacing="5" class="tblSales">
                    <tr>
                        <td>
                            <h3>
                                <asp:Label ID="Label1" Text='<%#Eval("ProductName")%>' runat="server" /></h3>
                            <h2>
                  <a  href='<%# "Products.aspx?ID=" + Eval("ProductID") %>'>Read More</a></h2>
                        </td>
                        <td >
                            <h4>
                                <asp:Label ID="Label2" Text='<%#Eval("ProductPrice")%>' runat="server" />,-</h4>      
                                <div> 
    <asp:Image ID="ProdImg" runat="server" AlternativeText="New product" ImageUrl='<%# "~/images/" + Eval("ImageFileName")' Visible="True"/><!--This picture should show in 30 days-->
                                  </div> 
                        </td>
                    </tr>
                    <hr />
                </table>
            </ItemTemplate>
    </asp:Repeater>
    

    CS codebehind

    protected void rptProducts_Databound(object sender, RepeaterItemEventArgs e)
    {
        var imgCtrl = (Image)e.Item.FindControl("ProdImg");
        var dataItem = (Product)e.Item.DataItem;
        imCtrl.Visible = dataItem.ProductAddedDate > DateTime.Now.AddDays(-30);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm trying to use OutputCaching in my ASP.NET MVC website. Problem is, when i
I'm trying to make my first game, a console tetris. I have a class
I am trying to make my first Sinatra + Mustache site but I am
This might be a dumb question...but I am trying to make my first app
I trying to make my first AJAX with JSON call using jQuery and CodeIgniter.
I'm trying to make my first app for Microsoft Surface. I need to use
I am trying to make my first app using XNA, and I am having
Hi I'm trying to make the first element of my observableArray hidden, the following
It's my first time trying to make anything really interesting in C# and I
I am trying to make two .exe files in c where first one store

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.