I want to load a DropDownList with possible Paises from my database.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Backend;
using Backend.Models;
namespace Frontend_UI_Web.Administrativos
{
public partial class Ciudad : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
PaisRepository paisRepo = new PaisRepository();
LoadPaises(paisRepo);
CiudadRepository ciudadRepo = new CiudadRepository();
}
private void LoadPaises(PaisRepository paisRepo)
{
//FindAll() returns a collection IQueryable<Pais>!
var Paises = paisRepo.FindAll().AsEnumerable();
uiddlPais.DataSource = Paises;
uiddlPais.DataBind();
}
protected void uibtnSubmit_Click(object sender, EventArgs e)
{
}
}
}
Any guidance? If I run this code the dropdownlist loads 5 items, which is correct since I have 5 paises. But the names aren't displayed correctly.