Click here to Skip to main content
15,898,374 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
In my repeater I have three fields: userdate,status and reason. I want to make the Edit linkbutton disabled when the diffrence between userdate and now date greater then 7.
Posted

try that

C#
int diff = userdate.Day - DateTime.Now.Day;//this is the difference in days if you want another difference
                                                   //ex in mon monthes use userdate.Month and so on
            if (diff > 7)
            {
                // Do something    linkbutton.Visible = true;
            }
 
Share this answer
 
Comments
pawankumar31 28-Feb-12 1:47am    
hi friend thnx for reply me i was using already this but when i am running my code then error is ocuuring
Object reference not set to an instance of an object on this line
linkbutton.Visible = true;
youssef_123 28-Feb-12 1:52am    
ok man this error means that your object is created but not instantiated (your object is null ex: Car blackCar;) in this case blackCar is null and you cant use any property in Class Car if you can send me your piece of code to know where is the error or tell me at which line of code regards
youssef_123 28-Feb-12 1:56am    
look man are you sure you create the linkbutton in a correct way (linkbutton linkbutton = new linkbutton();) and i prefer to create it in the aspx page ex:
<asp:LinkButton runat="server" ID="linkbutton" Text="blablabla">
waiting your reply
youssef_123 28-Feb-12 2:21am    
...
pawankumar31 28-Feb-12 4:43am    
thnx frnd for replying me i have solve my prob myself i add this line in my aspx page link button visible=<%#convert.toboolean(Eval("Enable"))%>
and take enable column in my datatable and give this value to behalf of my condition if (diff > 7) enable=false and bind this datatable to repeater
add this line in aspx page link button visible=<%#convert.toboolean(Eval("Enable"))%> and take extra enable column in datatable and give this value to behalf of your condition if (diff > 7) dr["enable"]=false and bind this datatable to repeater
 
Share this answer
 

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