protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { MovieServices listmovie = new MovieServices(); MoviePeopleServices castlist = new MoviePeopleServices(); List <MovieModelDTO> ListOfAllMovies = new List <MovieModelDTO>(); ListOfAllMovies = listmovie.GetAllMovies(); ddlTitleMovie.DataSource = ListOfAllMovies; ddlTitleMovie.DataBind(); ddlTitleMovie.Items.Insert(0, new ListItem("<-Choose Movie->", "0")); //------------------------------------------------------------------------- List <MovieModelDTO> ListOfYears = listmovie.GetAllYears(); List <string> Years = new List <string>(); foreach (var item in ListOfYears) { string year = item.Year; Years.Add(year); } ddlYearMovie.DataSource = Years.ToList().Distinct(); ddlYearMovie.DataBind(); ddlYearMovie.Items.Insert(0, new ListItem("<-Choose Year->", "0")); //----------------------------- List <MoviePersonDTO> ListOfAcotrs = castlist.GetActors(); ddlActorMovie.DataTextField = "FirstName"; ddlActorMovie.DataValueField = "LastName"; ddlActorMovie.DataSource = ListOfAcotrs; ddlActorMovie.DataBind(); ddlActorMovie.Items.Insert(0, new ListItem("<-Choose Actor->", "0")); //---------------------------------------------- List <MoviePersonDTO> ListOfProducers = castlist.GetProducers(); ddlProducerMovie.DataTextField = "FirstName"; ddlProducerMovie.DataValueField = "LastName"; ddlProducerMovie.DataSource = ListOfProducers; ddlProducerMovie.DataBind(); ddlProducerMovie.Items.Insert(0, new ListItem("<-Choose Producer->", "0")); //------------------------------------------------------- //genre to bind ddlGenreMovie.DataSource = listmovie.GetAllGenres(); ddlGenreMovie.DataBind(); ddlGenreMovie.Items.Insert(0, new ListItem("<-Choose Genre->", "0")); //repeater to bind List <MovieModelDTO> ListOfMovies = new List <MovieModelDTO>(); ListOfMovies = listmovie.GetAllMovies(); RepeaterMovie.DataSource = ListOfMovies; RepeaterMovie.DataBind(); } }