错误 - 得到类型错误匹配。 这是我的代码 - 请帮助
public void addDetailDescription(List<Detail> detailList) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
for (int i = 0; i < detailList.size(); i++) {
Log.e("vlaue inserting==", "" + detailList.get(i));
values.put(DETAIL_ID, String.valueOf(detailList.get(i)));
values.put(COLUMN_HEADING, String.valueOf(detailList.get(i)));
values.put(COLUMN_IMAGE_DETAIl, String.valueOf(detailList.get(i)));
values.put(COLUMN_DETAIL, String.valueOf(detailList.get(i)));
values.put(DETAIL_DESCRIPTION_ID, String.valueOf(detailList.get(i)));
}
db.insert(DESCRIPTION_DETAIL_TABLE, null, values);
db.close();
}
答案 0 :(得分:0)
我认为你必须编写这样的函数并在for循环中为每个列表项调用此函数。
@model BusinessModels.ClientBusinessModel
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}
@using (Html.BeginForm("Client", "Client", FormMethod.Post, new { @class = "leads-creation-form js-leads-creation-formr" }))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div>
<div>
<div>
@Html.LabelFor(model => model.ModeOfTransport)
<div>
@Html.DropDownListFor(model => model.ModeOfTransport, new SelectList(ViewBag.TransportList, "Text", "Value"), "")
</div>
</div>
<div>
@Html.LabelFor(model => model.TypeOfContainer)
<div>
<select id="TypeOfContainer" name="TypeOfContainer">
</select>
</div>
</div>
</div>
</div>
<div>
<button>
Submit
</button>
</div>
}
<script>
$("#ModeOfTransport").on("change", function(){
showValue($(this).val());
$("#TypeOfContainer").empty();
})
function showValue(val)
{
$.getJSON('@Url.Action("GetContainerList", "Client")' + "&value=" + val, function (result) {
var data = result.data;
for (var i = 0; i < data.length; i++) {
//console.log(data[i].value);
$("<option />", {
val: data[i].Text,
text: data[i].Value
}).appendTo("#TypeOfContainer");
//$("#TypeOfContainer").append("<option>" + data[i].Value + "</option>")
}
})
}
</script>
在你的代码中,每次都会更改contentValue,最后只会将最后一项插入数据库,这是完全错误的。