0

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.

2
Contributors
1
Reply
2
Views
4 Years
Discussion Span
Last Post by poojavb
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.