I have a dropdownlist control.
<asp:DropDownList runat="server" ID="ddlMarketerContract" CssClass="form-control" />
I set the DataSource in the code-behind using LINQ and EF
ddlMarketerContract.DataSource = context.Table.Select(x => x.ColumnName).Distinct().ToList();
But while stepping through the debug, when I go to bind the data
ddlMarketerContract.DataBind();
I get an "Object reference not set to an instance of an object" error.
Not sure why it lets me set the DataSource, but doesn't find the object when binding the control.
I have a similar setup on another page, but that works as expected. I thought maybe it's because I don't have DataTextField/DataValueField set, but the other page didn't have those set, and it still worked fine.