Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
i want to hide the date based on the database record.That is if the date is having record means i want to display date in dropdown list otherwise the date is to be hide in the dropdownlist..
how can i done this..

string[] date = new string[8];
DateTime dt = DateTime.UtcNow.AddHours(5.5);
DropDownList1.Items.Insert(0,"--SELECT DATE--");
DropDownList1.Items.Insert(1, new ListItem(dt.ToString("MM/dd/yyyy")));
for (int i = 1; i < 3; i++)
{
string s = dt.AddDays(-i).ToString("MM/dd/yyyy");
DropDownList1.Items.Insert(1+i, new ListItem(s, s));
}
this is my code to load date.i have call this in pageload().Three dates i nedd to display in dropdownlist.
if the date is not having values means i need to display date in dropdown..otherwise no need to display..
Can any one help me?
Posted
Updated 4-Dec-11 19:31pm
v3
Comments
koolprasad2003 5-Dec-11 1:14am    
confused ! Please explain it.
Karthik Harve 5-Dec-11 1:22am    
from where are you fetching the dates,,?? from database..?? any min and max dates..?? explain more..!!!!!!

1 solution

So what problem you are facing. If you have put all the items in aspx then you can remove the items(dates) from the dropdownlist on Load event.

Or better you get all possible dates from database and bind the dropdown dynamically.
 
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