Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
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 4-Dec-11 20:09pm
Edited 4-Dec-11 20:31pm
v3
Comments
koolprasad2003 at 5-Dec-11 1:14am
   
confused ! Please explain it.
Karthik Harve at 5-Dec-11 1:22am
   
from where are you fetching the dates,,?? from database..?? any min and max dates..?? explain more..!!!!!!

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 DamithSL 295
1 OriginalGriff 214
2 BillWoodruff 170
3 Zoltán Zörgő 165
4 Maciej Los 113
0 OriginalGriff 7,760
1 DamithSL 5,874
2 Sergey Alexandrovich Kryukov 5,444
3 Maciej Los 5,076
4 Kornfeld Eliyahu Peter 4,539


Advertise | Privacy | Mobile
Web01 | 2.8.141223.1 | Last Updated 5 Dec 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100