Web Tutorials

Interview Q & A

Code Examples

Utility Tools

ASP.NET Page InitComplete Event and Initialise DropDown List

ASP.NET InitComplete event is used to initialise DropDown List and set values. This event will fired first time when page initialization completed in asp.net page life cycle.

Syntax

protected void Page_InitComplete(object sender, EventArgs e)
{
	//Code will come here.  
}

ASP.NET Page InitComplete Event and Initialise DropDown List Example - Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" 
Inherits="_Default" %>
<!DOCTYPE html">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Label ID="lblTitle" runat="server" Text="ASP.NET Page Life Cycle"></asp:Label><br />
        <asp:dropdownlist id="CountryDropDownList" runat="server"></asp:dropdownlist>
    </div>
    </form>
</body>
</html>

ASP.NET Page InitComplete Event and Initialise DropDown List Example - Default.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_InitComplete(object sender, EventArgs e) 
	{ 
	     ArrayList list = new ArrayList();
         list.Add("none");
         list.Add("AF");
         list.Add("AL");
		 list.Add("DZ");
         list.Add("AS");
    
         CountryDropDownList.DataSource = list;
         CountryDropDownList.DataBind();
	}
}

RequiredFieldValidator

RegularExpressionValidator

RangValidator

CompareValidator

CustomValidator

ValidationSummary