Country wise Date and time print using Dropdownlist in asp.net


Country wise Date And Time

If you want to select country into dropdownlist then selected country Date and time is display in label
this is Aspx page.

 <asp:DropDownList ID="ddlcountry" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlcountry_SelectedIndexChanged">
<asp:ListItem>select country</asp:ListItem>
<asp:ListItem Text="India,Sri Lanka" Value="India"> </asp:ListItem>
<asp:ListItem Text="United Kingdom,"
Value="United Kingdom"> </asp:ListItem>
<asp:ListItem Text="France,Spain,Slovenia,Slovakia,Poland,Norway,Nigeria,Niger,Monaco,Netherlands"
Value="France"> </asp:ListItem>
<asp:ListItem Text="Botswana,Moldova,Latvia,Estonia,Belarus,South Africa,Rwanda"
Value="Botswana"> </asp:ListItem>
<asp:ListItem Text="Senegal" Value="Senegal"> </asp:ListItem>
<asp:ListItem Text="France" Value="France"> </asp:ListItem>
<asp:ListItem Text="Spain" Value="Spain"> </asp:ListItem>
<asp:ListItem Text="Botswana" Value="Botswana"> </asp:ListItem>
<asp:ListItem Text="South Africa" Value="South Africa"> </asp:ListItem>
<asp:ListItem Text="Bahrain" Value="Bahrain"> </asp:ListItem>
<asp:ListItem Text="Iran" Value="Iran"> </asp:ListItem>
<asp:ListItem Text="United Arab Emirates" Value="United Arab Emirates"> </asp:ListItem>
<asp:ListItem Text="Afghanistan" Value="Afghanistan"> </asp:ListItem>
<asp:ListItem Text="Pakistan" Value="Pakistan"> </asp:ListItem>
<asp:ListItem Text="Nepal" Value="Pakistan"> </asp:ListItem>
<asp:ListItem Text="Bangladesh" Value="Pakistan"> </asp:ListItem>
<asp:ListItem Text="Myanmar" Value="Pakistan"> </asp:ListItem>
<asp:ListItem Text="Cambodia" Value="Pakistan"> </asp:ListItem>
<asp:ListItem Text="Singapore" Value="Pakistan"> </asp:ListItem>
<asp:ListItem Text="China" Value="Pakistan"> </asp:ListItem>
<asp:ListItem Text="Japan" Value="Pakistan"> </asp:ListItem>
<asp:ListItem Text="Zimbabwe" Value="Pakistan"> </asp:ListItem>
<asp:ListItem Text="USA" Value="Pakistan"> </asp:ListItem>
<asp:ListItem Text="Switzerland" Value="Pakistan"> </asp:ListItem>
<asp:ListItem Text="Bahrain,Somalia,Saudi Arabia,Russia,Qatar,Sudan,Madagascar,Kuwait,Kenya,Ethiopia,Djibouti,Iraq,Lesotho,Burundi"
Value="Behrain"></asp:ListItem>
<asp:ListItem Text="Iran" Value="Iran"></asp:ListItem>
<asp:ListItem Text="Armenia,Seychelles,Reunion,Oman,Mauritius,United Arab Emirates,Georgia,Azerbaijan"
Value="Armenia"></asp:ListItem>
<asp:ListItem Text="Afghanistan" Value="Afghanistan"></asp:ListItem>
<asp:ListItem Text="Pakistan,Maldives,Kyrgyzstan" Value="Pakistan"></asp:ListItem>
<asp:ListItem Text="Nepal" Value="Nepal"></asp:ListItem>
<asp:ListItem Text="Bangladesh,Kazakhstan" Value="Bangladesh"></asp:ListItem>
<asp:ListItem Text="Myanmar" Value="Myanmar"></asp:ListItem>
<asp:ListItem Text="Cambodia,Laos" Value="Cambodia"></asp:ListItem>
<asp:ListItem Text="Philippines,Mongolia,Macau,Indonesia,Brunei,Malaysia,Hong Kong,China"
Value="Philippines"></asp:ListItem>
<asp:ListItem Text="Japan,Korea" Value="Japan"></asp:ListItem>
<asp:ListItem Text="Micronesia" Value="Micronesia"></asp:ListItem>
<asp:ListItem Text="Papua New Guinea,Australia" Value="Papua New Guinea"></asp:ListItem>
<asp:ListItem Text="New Caledonia" Value="New Caledonia"></asp:ListItem>
<asp:ListItem Text="New Zealand,Fiji" Value="New Zealand"></asp:ListItem>
<asp:ListItem Text="Argentina,Brazil" Value="Argentina"></asp:ListItem>
<asp:ListItem Text="Cuba" Value="Cuba"></asp:ListItem>
<asp:ListItem Text="Aruba,Puerto Rico,Paraguay,Netherlands Antilles,Barbados,Grenada,Bolivia,Chile,Dominican Republic,Guyana"
Value="Aruba"></asp:ListItem>
<asp:ListItem Text="Bahamas" Value="Bahamas"></asp:ListItem>
<asp:ListItem Text="Peru,Panama,Jamaica,Haiti,Ecuador,Colombia,Canary Islands" Value="Peru"></asp:ListItem>
<asp:ListItem Text="Bhutan" Value="Bhutan"></asp:ListItem>
<asp:ListItem Text="Belize,Mexico,Honduras,Guatemala,El Salvador,Canada,Costa Rica"
Value="Belize"></asp:ListItem>
<asp:ListItem Text="Nicaragua" Value="Nicaragua"></asp:ListItem>
<asp:ListItem Text="United States Of America" Value="United States Of America"></asp:ListItem>
<asp:ListItem Text="French Polynesia" Value="French Polynesia"></asp:ListItem>
<asp:ListItem Text="Samoa" Value="Samoa"></asp:ListItem>
<asp:ListItem Text="Singapore" Value="Singapore"></asp:ListItem>
<asp:ListItem Text="Slovak Republic" Value="Slovak Republic"></asp:ListItem>
<asp:ListItem Text="Solomon Islands" Value="Solomon Islands"></asp:ListItem>
<asp:ListItem Text="St Helena" Value="St Helena"></asp:ListItem>
<asp:ListItem Text="St Kitts & Nevia" Value="St Kitts & Nevia"></asp:ListItem>
<asp:ListItem Text="St Lucia" Value="St Lucia"></asp:ListItem>
<asp:ListItem Text="Surinam" Value="Surinam"></asp:ListItem>
<asp:ListItem Text="Swaziland" Value="Swaziland"></asp:ListItem>
<asp:ListItem Text="Sweden" Value="Sweden"></asp:ListItem>
<asp:ListItem Text="Switzerland" Value="Switzerland"></asp:ListItem>
<asp:ListItem Text="Syria" Value="Syria"></asp:ListItem>
<asp:ListItem Text="Taiwan" Value="Taiwan"></asp:ListItem>
<asp:ListItem Text="Tajikistan" Value="Tajikistan"></asp:ListItem>
<asp:ListItem Text="Tanzania" Value="Tanzania"></asp:ListItem>
<asp:ListItem Text="Thailand" Value="Thailand"></asp:ListItem>
<asp:ListItem Text="Tonga" Value="Tonga"></asp:ListItem>
<asp:ListItem Text="Trinidad & Tobago" Value="Trinidad & Tobago"></asp:ListItem>
<asp:ListItem Text="Tunisia" Value="Tunisia"></asp:ListItem>
<asp:ListItem Text="Turkmenistan" Value="Turkmenistan"></asp:ListItem>
<asp:ListItem Text="Turks & Caicos Islands" Value="Turks & Caicos Islands"></asp:ListItem>
<asp:ListItem Text="Tuvalu" Value="Tuvalu"></asp:ListItem>
<asp:ListItem Text="Uganda" Value="Uganda"></asp:ListItem>
<asp:ListItem Text="Ukraine" Value="Ukraine"></asp:ListItem>
<asp:ListItem Text="Uruguay" Value="Uruguay"></asp:ListItem>
<asp:ListItem Text="USA" Value="USA"></asp:ListItem>
<asp:ListItem Text="Uzbekistan" Value="Uzbekistan"></asp:ListItem>
<asp:ListItem Text="Vanuatu" Value="Vanuatu"></asp:ListItem>
<asp:ListItem Text="Venezuela" Value="Venezuela"> </asp:ListItem>
<asp:ListItem Text="Vietnam" Value="Vietnam"> </asp:ListItem>
<asp:ListItem Text="Wallis & Futuna Islands" Value="Wallis & Futuna Islands"> </asp:ListItem>
<asp:ListItem Text="Yemen" Value="Yemen"> </asp:ListItem>
<asp:ListItem Text="Zambia" Value="Zambia"> </asp:ListItem>
<asp:ListItem Text="Zimbabwe" Value="Zimbabwe"> </asp:ListItem>
</asp:DropDownList>
<asp:Label ID="lbltime" runat="server" Font-Bold="true" Font-Size="Medium" Font-Names="arial"
ForeColor="Red"></asp:Label>

GetCountryTime function is called when ever dropdown value changed and print date time value into label.

 protected void ddlcountry_SelectedIndexChanged(object sender, EventArgs e)
{
lbltime.Text=GetCountryTime(ddlcountry.SelectedValue.ToString());

}
private string GetCountryTime(string country)
{
DateTime gmt = default(DateTime);
System.DateTime value = default(System.DateTime);
gmt = DateTime.Now.AddMinutes(-330);

switch (country)
{
case "India":
case "Sri Lanka":
return DateTime.Now.ToString();
case "United Kingdom":
case "Portugal":
case "Sierra Leone":
case "Senegal":
case "Morocco":
case "Mali":
return gmt.ToString();
case "France":
case "Spain":
case "Slovenia":
case "Slovakia":
case "Poland":
case "Nigeria":
case "Niger":
case "Hungary":
case "Denmark":
case "Czech Republic":
return gmt.AddMinutes(60).ToString();
case "Botswana":
case "Moldova":
case "South Africa":
case "Malawi":
case "Lithuania":
case "Libya":
case "Turkey":
case "Finland":
case "Egypt":
return gmt.AddMinutes(120).ToString(); ;
case "Bahrain":
case "Somalia":
case "Saudi Arabia":
case "Russia":
case "Qatar":
case "Sudan":
case "Madagascar":
case "Iraq":
return gmt.AddMinutes(180).ToString();
case "Iran":
return gmt.AddMinutes(220).ToString();
case "Armenia":
case "Seychelles":
case "Reunion":
case "Oman":
case "Mauritius":
case "United Arab Emirates":
case "Georgia":
case "Azerbaijan":
return gmt.AddMinutes(240).ToString();
case "Afghanistan":
return gmt.AddMinutes(270).ToString();
case "Pakistan":
case "Maldives":
case "Kyrgyzstan":
return gmt.AddMinutes(300).ToString();
case "Nepal":
return gmt.AddMinutes(345).ToString();
case "Bangladesh":
case "Kazakhstan":
return gmt.AddMinutes(360).ToString();
case "Myanmar":
return gmt.AddMinutes(390).ToString();
case "Cambodia":
case "Laos":
return gmt.AddMinutes(420).ToString();
case "Philippines":
case "Malaysia":
case "Hong Kong":
case "China":
return gmt.AddMinutes(480).ToString();
case "Japan":
case "Korea":
return gmt.AddMinutes(540).ToString();
case "Micronesia":
return gmt.AddMinutes(720).ToString();
case "Papua New Guinea":
case "Australia":
return gmt.AddMinutes(600).ToString();
case "New Caledonia":
return gmt.AddMinutes(660).ToString();
case "New Zealand":
case "Fiji":
return gmt.AddMinutes(720).ToString();
case "Argentina":
case "Brazil":
return gmt.AddMinutes(-180).ToString();
case "Cuba":
return gmt.AddMinutes(-300).ToString();
case "Aruba":
case "Paraguay":
case "Netherlands Antilles":
case "Barbados":
case "Chile":
case "Dominican Republic":
case "Guyana":
return gmt.AddMinutes(-240).ToString();
case "Bahamas":
return gmt.AddMinutes(-240).ToString();
case "Peru":
case "Panama":
case "Jamaica":
case "Haiti":
case "Colombia":
case "Canary Islands":
return gmt.AddMinutes(-300).ToString();
case "Bhutan":
return gmt.AddMinutes(360).ToString();
case "Belize":
case "Mexico":
case "Honduras":
case "Canada":
return gmt.AddMinutes(-360).ToString();
case "Nicaragua":
return gmt.AddMinutes(-300).ToString();

case "United States Of America":
return gmt.AddMinutes(-480).ToString();
case "French Polynesia":
return gmt.AddMinutes(720).ToString();
case "Samoa":
return gmt.AddMinutes(-660).ToString();
case "Singapore":
return gmt.AddMinutes(480).ToString();
case "Slovak Republic":
return gmt.AddMinutes(60).ToString();
case "Solomon Islands":
return gmt.AddMinutes(660).ToString();
case "St Helena":
return gmt.AddMinutes(0).ToString();
case "St Kitts & Nevia":
return gmt.AddMinutes(-240).ToString();
case "St Lucia":
return gmt.AddMinutes(-240).ToString();
case "Surinam":
return gmt.AddMinutes(-180).ToString();
case "Swaziland":
return gmt.AddMinutes(120).ToString();
case "Sweden":
return gmt.AddMinutes(60).ToString();
case "Switzerland":
return gmt.AddMinutes(60).ToString();
case "Syria":
return gmt.AddMinutes(120).ToString();
case "Taiwan":
return gmt.AddMinutes(480).ToString();
case "Tajikistan":
return gmt.AddMinutes(300).ToString();
case "Tanzania":
return gmt.AddMinutes(180).ToString();
case "Thailand":
return gmt.AddMinutes(420).ToString();
case "Tonga":
return gmt.AddMinutes(0).ToString();
case "Trinidad & Tobago":
return gmt.AddMinutes(-240).ToString();
case "Tunisia":
return gmt.AddMinutes(60).ToString();
case "Turkmenistan":
return gmt.AddMinutes(300).ToString();
case "Turks & Caicos Islands":
return gmt.AddMinutes(-240).ToString();
case "Tuvalu":
return gmt.AddMinutes(720).ToString();
case "Uganda":
return gmt.AddMinutes(180).ToString();
case "Ukraine":
return gmt.AddMinutes(120).ToString();
case "Uruguay":
return gmt.AddMinutes(-180).ToString();
case "USA":
return gmt.AddMinutes(-480).ToString();
case "Uzbekistan":
return gmt.AddMinutes(300).ToString();
case "Vanuatu":
return gmt.AddMinutes(660).ToString();
case "Venezuela":
return gmt.AddMinutes(-240).ToString();
case "Vietnam":
return gmt.AddMinutes(420).ToString();
case "Wallis & Futuna Islands":
return gmt.AddMinutes(720).ToString();
case "Yemen":
return gmt.AddMinutes(180).ToString();
case "Zambia":
return gmt.AddMinutes(120).ToString();
case "Zimbabwe":
return gmt.AddMinutes(120).ToString();
default:
return "";
}
}


Ebook Download
View all
Learn
View all