Hello,
I've the following code to bind:
I've the following code to bind:
var lstEmployees = employeeRepository.All.Select(employee => new { employee.Id, employee.Name });
txtEmployee.DataSource = lstEmployees.ToList();
txtEmployee.DataTextField = "Name";
txtEmployee.DataValueField = "Id";
txtEmployee.DataBind();
This code is called in the Page_Load() event inside the
if (!IsPostBack) block.
This triggers the error "The Control DataSource or (DataSourceID) is not set" when I start typing into it.
What I noticed is, when I move the binding code outside the if (!IsPostBack) block, it works correctly.