I have a dropdown list as below:
DropDownList1.DataSource = Students.GetStudents();
DropDownList1.DataBind();
-----------
I have a DataAccess Class as below:
public IEnumerable<StudentEntity> GetStudents()
{
List<StudentsEntity> studentsList = new List<StudentsEntity>();
studentsList = Service.GetList() // some service getting a list of sutdents
return new BindingList<StudentEntity>(studentsList);
}
I have a DataObject Class as below:
public class StudentEntity : IComparable
{
public string fullname { get {return firstName +", "+ lastName;}
public string ID {get; set;}
public string Height {get; set;}
public string Firstname {get; set;}
public string Lastname {get; set;}
public int CompareTo(object obj)
{
StudentEntity entity = (StudentEntity) obj;
return Lastname.CompareTo(entity.Lastname);
}
}
At the UI level - the 'Students Fullname' is displayed in the dropdown list, so how can I get the 'ID' of the Selected Student from the DropDown List?