Reputation: 10476
I'm attempting to data-bind a value to an ASP.NET DropDownList but the server complains that it doesn't recognize the data-bind attribute:
<%=Html.DropDownList("accountSiteInstanceId", ViewData["degreePrograms"] as SelectList, new { @data-bind = "value: DegreeProgramId" } ) %>
I get the following error: Compiler Error Message: CS0746: Invalid anonymous type member declarator. Anonymous type members must be declared with a member assignment, simple name or member access.
Upvotes: 1
Views: 2138
Reputation: 875
change the dash into an underscore and it will convert it back to dash on runtime.
Upvotes: 4
Reputation: 8168
The problem is the dash. Use dictionary based notation:
<%= Html.DropDownList("accountSiteInstanceId", ViewData["degreePrograms"] as SelectList, new Dictionary<string, object>
{
{"data-bind",
"DegreeProgramId"}
}) %>
Upvotes: 5