Click here to Skip to main content
15,889,876 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hello, i have table(gridview) with 4 col on of them is expiredate, in code behind i did
if statement to show me only the row that will appear when the expire date in 45 days, (( but now i need when the specific row appear based on expire send email that something will expire and link to page that have table that i did

i search for bit about it, be careful that i cant use sql agent because of sql version don't have it.

thank u..

What I have tried:

C#
<pre>   }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {


        GridView1.Columns[4].Visible = false;
        
        
          Label a = e.Row.FindControl("Label2") as Label;
          Label b = e.Row.FindControl("Label3") as Label;
         
        if ((a != null) & (b!= null))
        {
            DateTime lblDate;
            if ((!DateTime.TryParse(a.Text, out lblDate)) & (!DateTime.TryParse(b.Text, out lblDate)))
            {
                // date time conversion not success 
                // you may have empty or invalid datetime 
                // do something in this case 
                return;
            }
            
            if (lblDate <= DateTime.Today.AddDays(45))
            {

                e.Row.Visible = true;

            }

            else
            {
e.Row.Visible = false;
          
            }
Posted
Updated 29-Mar-17 1:09am
v3
Comments
[no name] 29-Mar-17 7:05am    
"i cant use sql agent " so write a service or use the task scheduler.

1 solution

ASP.Net code only runs when someone visits one of your pages. If you need to schedule things, you do not use ASP.Net but instead you can write a Windows Service or a console app that you schedule with Task Scheduler.
 
Share this answer
 
Comments
Member 13044689 29-Mar-17 7:26am    
can u recommend me an article or something will help me
ZurdoDev 29-Mar-17 7:51am    
Just google c# window service, for example.
Member 13044689 29-Mar-17 8:25am    
ok sir thank u , one more thing what do u mean in your first comment my condition is wrong , but i need this with windows service , and i want someone to visit so it's wrong?
ZurdoDev 29-Mar-17 9:16am    
I'm not sure what you are asking. IF you want someone to visit then yes, you clearly need ASP.Net web pages. But to send the email, you'll need a separate service.
Member 13044689 29-Mar-17 15:57pm    
ok thanks

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