http://www.hanselman.com/blog/SplittingDateTimeUnitTestingASPNETMVCCustomModelBinders.aspx
Stack Overflow也有:
較簡單的範例
有時間再來寫實際實作過程...
//使用Ajax取得Json格式的資料 格式為 List
$.ajax({
type: 'GET',
url: GetUrl,
data: { id: id },
dataType: "json",
success: function (data) {
$("#selectId").fillSelect(data);
}
});
//清除選取的下拉清單
$.fn.clearSelect = function() {
return this.each(function() {
if (this.tagName == 'SELECT')
this.options.length = 0;
});
}
//將下拉選項加入下拉清單
$.fn.fillSelect = function (data, selectId) {
return this.clearSelect().each(function () {
if (this.tagName == 'SELECT') {
var dropdownList = this;
$.each(data, function (index, optionData) {
var option = new Option(optionData.Text, optionData.Value);
if ($.browser.msie) {
dropdownList.add(option);
}
else {
dropdownList.add(option, null);
}
});
}
});
}
var items = from c in contacts
select new ListItem
{
Value = SqlFunctions.StringConvert((double)c.ContactId),
Text = c.Name
};