To solve the error follow the following steps:
Step 1: Go to Control Panel -> Programs and Features
-> Turn Windows Features on or off
Step 2: Mark the features as like following image.
Step 3: Click OK and reset IIS.
public class StudentInfo { public int Id { get; set; } public string Name { get; set; } }
protected void Page_Load(object sender, EventArgs e) { ListlstStudentInfo = new List (); StudentInfo objStudentInfo1 = new StudentInfo(); objStudentInfo1.Id = 1; objStudentInfo1.Name = "Mahedee Hasan"; lstStudentInfo.Add(objStudentInfo1); StudentInfo objStudentInfo2 = new StudentInfo(); objStudentInfo2.Id = 2; objStudentInfo2.Name = "Mahmud Ahsan"; lstStudentInfo.Add(objStudentInfo2); StudentInfo objStudentInfo3 = new StudentInfo(); objStudentInfo3.Id = 3; objStudentInfo3.Name = "Asrafuzzaman"; lstStudentInfo.Add(objStudentInfo3); StudentInfo objStudentInfo4 = new StudentInfo(); objStudentInfo4.Id = 4; objStudentInfo4.Name = "Enamul Haque"; lstStudentInfo.Add(objStudentInfo4); ddlStudentInfo.DataSource = lstStudentInfo; ddlStudentInfo.DataValueField = "Id"; ddlStudentInfo.DataTextField = "Name"; ddlStudentInfo.SelectedIndex = 2; //Selected index 2 means selected value is 3 and text is Asrafuzzaman ddlStudentInfo.DataBind(); }