在 MVC 3 中,我需要将 DropDownList 绑定到元组...我收到以下错误:
你能告诉我在这里做错了什么吗?谢谢
错误
DataBinding: 'System.Tuple`2[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]' does not contain a property with the name 'Value'.
剃刀
@Html.DropDownListFor(
x => x.RemindersList,
new SelectList(Model.RemindersList, "Value", "Text")
)
类(传递给 ViewModel 的实例)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace AshtonEventsMobile
{
public class Reminders
{
public List<Tuple<int, string>> TimeSpanText { get; set; }
// We are setting the default values using the Costructor
public Reminders()
{
List<Tuple<int, string>> timeSpanText = new List<Tuple<int, string>>();
Tuple<int, string> reminder0 = new Tuple<int, string>(0, "None");
timeSpanText.Add(reminder0);
Tuple<int, string> reminder1 = new Tuple<int, string>(300, "5 minutes before");
timeSpanText.Add(reminder1);
Tuple<int, string> reminder2 = new Tuple<int, string>(900, "15 minutes before");
timeSpanText.Add(reminder2);
Tuple<int, string> reminder3 = new Tuple<int, string>(1800, "30 minutes before");
timeSpanText.Add(reminder3);
Tuple<int, string> reminder4 = new Tuple<int, string>(3600, "1 hour before");
timeSpanText.Add(reminder4);
Tuple<int, string> reminder5 = new Tuple<int, string>(7200, "2 hours before");
timeSpanText.Add(reminder5);
Tuple<int, string> reminder6 = new Tuple<int, string>(86400, "1 day before");
timeSpanText.Add(reminder6);
Tuple<int, string> reminder7 = new Tuple<int, string>(172800, "2 day before");
timeSpanText.Add(reminder7);
TimeSpanText = timeSpanText;
}
}
}