I am having trouble with databinding when trying to add it to a dropdownlist. I can get it to work with a label:
<asp:Label ID="Label3" runat="server" Text='<%# Eval("Location") %>'></asp:Label>
But when I try with the DropDownList I get this error and I can't seem to find an answer for it.
Databinding expressions are only supported on objects that have a DataBinding event. System.Web.UI.WebControls.ListItem does not have a DataBinding event.
Here is the code I use:
<asp:DropDownList ID="ddlLocation1" runat="server">
<asp:ListItem Text='<%# Eval("Location") %>' Value='<%# Eval("TotalCost") %>' />
</asp:DropDownList>
Any help would be greatly appreciated.