Monday, June 25, 2018

Populating TimeZone list in ASP Net

Populating TimeZone list in ASP Net


Following code will populate the controls in asp.net:

//Populating in DropDownList (1)
this.DropDownList1.DataSource = TimeZoneInfo.GetSystemTimeZones();
this.DropDownList1.DataBind();

//Populating in DropDownList (2)
foreach (TimeZoneInfo tmz in TimeZoneInfo.GetSystemTimeZones())
{
this.DropDownList1.Items.Add(new ListItem(tmz.DisplayName, tmz.Id));
}
//Populating in GridView
GridView1.DataSource = TimeZoneInfo.GetSystemTimeZones();
GridView1.DataBind();

go to link download

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.