This is a migrated thread and some comments may be shown as answers.

The Control DataSource or (DataSourceID) is not set

1 Answer 286 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Mohamed
Top achievements
Rank 1
Mohamed asked on 11 Apr 2013, 01:36 PM
Hello,

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.

 

 

 

 

 

 

 

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 16 Apr 2013, 07:33 AM
Hi Mohamed,

I was able to replicate the issue. On removing the !IsPostBack from the page load, it worked fine for me.

Thanks,
Princy.
Tags
AutoCompleteBox
Asked by
Mohamed
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or