- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我认为有以下网络网格:
@using (Html.BeginForm("InsertSensorsInExistingPredefineView", "PredefinedViews", FormMethod.Post))
{
@gridSensorChoose.GetHtml(
tableStyle: "webgrid3-table",
headerStyle: "webgrid3-header",
footerStyle: "webgrid3-footer",
alternatingRowStyle: "webgrid3-alternating-row",//
selectedRowStyle: "webgrid3-selected-row",
rowStyle: "webgrid3-row-style",//
mode: WebGridPagerModes.All,
columns:
gridSensorChoose.Columns(
gridSensorChoose.Column("SensorID", format: @<text> <input readonly="readonly" name="SensorID" id="SensorID" value="@item.SensorID" /> </text>, style: "col1Width"),
gridSensorChoose.Column("DeviceID", format: @<text> <span id="DeviceID">@item.DeviceID</span> </text>, style: "col1Width"),
gridSensorChoose.Column("SensorType", format: @<text> <span id="SensorType" class="SensorType">@item.SensorType</span> </text>, style: "col1Width"),
gridSensorChoose.Column("SensorName", @Html.Localize("sensorName").ToString(), format: @<text> <span><label id="SensorName">@item.SensorName</label> </span> </text>, style: "col2Width", canSort: false),
gridSensorChoose.Column("VAL", format: @<text><span class="Val"> @Html.CheckBox("val") </span></text>, style:"col1Width", canSort: false),
gridSensorChoose.Column("MIN", format: @<text><span class="Min"> @Html.CheckBox("min") </span> </text>, style: "col1Width", canSort: false),
gridSensorChoose.Column("AVG", format: @<text> <span class="Avg"> @Html.CheckBox("avg") </span> </text>, style: "col1Width", canSort: false),
gridSensorChoose.Column("MAX", format: @<text> <span class="Max"> @Html.CheckBox("max") </span> </text>, style: "col1Width", canSort: false),
gridSensorChoose.Column("SUM", format: @<text> <span class="Sum"> @Html.CheckBox("sum") </span> </text>, style: "col1Width", canSort: false),
gridSensorChoose.Column("INT", format: @<text> <span class="Int"> @Html.CheckBox("int") </span> </text>, style: "col1Width", canSort: false)
))
<input type="submit" value="@Html.Localize("save")" formaction="/PredefinedViews/InsertSensorsInExistingPredefineView" />
}
此 View 在浏览器中显示以下 html,如下所示:
<table class="webgrid3-table">
<thead>
<tr class="webgrid3-header">
<th scope="col" style="display: none;">
<a href="/PredefinedViews/CreateSensorList? selDeviceID=1&sort=SensorID&sortdir=ASC">SensorID</a>
</th>
<th scope="col" style="display: none;">
<a href="/PredefinedViews/CreateSensorList?selDeviceID=1&sort=DeviceID&sortdir=ASC">DeviceID</a>
</th>
<th scope="col" style="display: none;">
<a href="/PredefinedViews/CreateSensorList?selDeviceID=1&sort=SensorType&sortdir=ASC">SensorType</a>
</th>
<th scope="col">
Sensor Name
</th>
<th scope="col">
VAL
</th>
<th scope="col">
MIN
</th>
<th scope="col">
AVG
</th>
<th scope="col">
MAX
</th>
<th scope="col">
SUM
</th>
<th scope="col">
INT
</th>
</tr>
</thead>
<tbody>
<tr class="webgrid3-row-style">
<td class="col1Width" style="display: none;"> <span id="SensorID">1</span> </td>
<td class="col1Width" style="display: none;"> <span id="DeviceID">1</span> </td>
<td class="col1Width" style="display: none;"> <span id="SensorType" class="SensorType">10</span> </td>
<td class="col2Width"> <span><label id="SensorName">Soil Temperature </label> </span> </td>
<td class="col1Width"><span class="Val"> <input id="val" name="val" type="checkbox" value="true"><input name="val" type="hidden" value="false"> </span></td>
<td class="col1Width"><span class="Min"> <input id="min" name="min" type="checkbox" value="true"><input name="min" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Avg"> <input id="avg" name="avg" type="checkbox" value="true"><input name="avg" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Max"> <input id="max" name="max" type="checkbox" value="true"><input name="max" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Sum" style="display: none;"> <input id="sum" name="sum" type="checkbox" value="true"><input name="sum" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Int" style="display: none;"> <input id="int" name="int" type="checkbox" value="true"><input name="int" type="hidden" value="false"> </span> </td>
</tr>
<tr class="webgrid3-alternating-row">
<td class="col1Width" style="display: none;"> <span id="SensorID">2</span> </td>
<td class="col1Width" style="display: none;"> <span id="DeviceID">1</span> </td>
<td class="col1Width" style="display: none;"> <span id="SensorType" class="SensorType">1</span> </td>
<td class="col2Width"> <span><label id="SensorName">Soil Moisture na 15cm</label> </span> </td>
<td class="col1Width"><span class="Val"> <input id="val" name="val" type="checkbox" value="true"><input name="val" type="hidden" value="false"> </span></td>
<td class="col1Width"><span class="Min"> <input id="min" name="min" type="checkbox" value="true"><input name="min" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Avg"> <input id="avg" name="avg" type="checkbox" value="true"><input name="avg" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Max"> <input id="max" name="max" type="checkbox" value="true"><input name="max" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Sum" style="display: none;"> <input id="sum" name="sum" type="checkbox" value="true"><input name="sum" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Int" style="display: none;"> <input id="int" name="int" type="checkbox" value="true"><input name="int" type="hidden" value="false"> </span> </td>
</tr>
<tr class="webgrid3-row-style">
<td class="col1Width" style="display: none;"> <span id="SensorID">3</span> </td>
<td class="col1Width" style="display: none;"> <span id="DeviceID">1</span> </td>
<td class="col1Width" style="display: none;"> <span id="SensorType" class="SensorType">1</span> </td>
<td class="col2Width"> <span><label id="SensorName">Soil Moisture na 30cm</label> </span> </td>
<td class="col1Width"><span class="Val"> <input id="val" name="val" type="checkbox" value="true"><input name="val" type="hidden" value="false"> </span></td>
<td class="col1Width"><span class="Min"> <input id="min" name="min" type="checkbox" value="true"><input name="min" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Avg"> <input id="avg" name="avg" type="checkbox" value="true"><input name="avg" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Max"> <input id="max" name="max" type="checkbox" value="true"><input name="max" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Sum" style="display: none;"> <input id="sum" name="sum" type="checkbox" value="true"><input name="sum" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Int" style="display: none;"> <input id="int" name="int" type="checkbox" value="true"><input name="int" type="hidden" value="false"> </span> </td>
</tr>
<tr class="webgrid3-alternating-row">
<td class="col1Width" style="display: none;"> <span id="SensorID">4</span> </td>
<td class="col1Width" style="display: none;"> <span id="DeviceID">1</span> </td>
<td class="col1Width" style="display: none;"> <span id="SensorType" class="SensorType">101</span> </td>
<td class="col2Width"> <span><label id="SensorName">Leaf wetness prvi</label> </span> </td>
<td class="col1Width"><span class="Val"> <input id="val" name="val" type="checkbox" value="true"><input name="val" type="hidden" value="false"> </span></td>
<td class="col1Width"><span class="Min" style="display: none;"> <input id="min" name="min" type="checkbox" value="true"><input name="min" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Avg" style="display: none;"> <input id="avg" name="avg" type="checkbox" value="true"><input name="avg" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Max" style="display: none;"> <input id="max" name="max" type="checkbox" value="true"><input name="max" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Sum"> <input id="sum" name="sum" type="checkbox" value="true"><input name="sum" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Int" style="display: none;"> <input id="int" name="int" type="checkbox" value="true"><input name="int" type="hidden" value="false"> </span> </td>
</tr>
<tr class="webgrid3-row-style">
<td class="col1Width" style="display: none;"> <span id="SensorID">5</span> </td>
<td class="col1Width" style="display: none;"> <span id="DeviceID">1</span> </td>
<td class="col1Width" style="display: none;"> <span id="SensorType" class="SensorType">201</span> </td>
<td class="col2Width"> <span><label id="SensorName">Ait temperature </label> </span> </td>
<td class="col1Width"><span class="Val"> <input id="val" name="val" type="checkbox" value="true"><input name="val" type="hidden" value="false"> </span></td>
<td class="col1Width"><span class="Min" style="display: none;"> <input id="min" name="min" type="checkbox" value="true"><input name="min" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Avg" style="display: none;"> <input id="avg" name="avg" type="checkbox" value="true"><input name="avg" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Max" style="display: none;"> <input id="max" name="max" type="checkbox" value="true"><input name="max" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Sum" style="display: none;"> <input id="sum" name="sum" type="checkbox" value="true"><input name="sum" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Int"> <input id="int" name="int" type="checkbox" value="true"><input name="int" type="hidden" value="false"> </span> </td>
</tr>
<tr class="webgrid3-alternating-row">
<td class="col1Width" style="display: none;"> <span id="SensorID">6</span> </td>
<td class="col1Width" style="display: none;"> <span id="DeviceID">1</span> </td>
<td class="col1Width" style="display: none;"> <span id="SensorType" class="SensorType">202</span> </td>
<td class="col2Width"> <span><label id="SensorName">Air humidity </label> </span> </td>
<td class="col1Width"><span class="Val"> <input id="val" name="val" type="checkbox" value="true"><input name="val" type="hidden" value="false"> </span></td>
<td class="col1Width"><span class="Min" style="display: none;"> <input id="min" name="min" type="checkbox" value="true"><input name="min" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Avg" style="display: none;"> <input id="avg" name="avg" type="checkbox" value="true"><input name="avg" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Max" style="display: none;"> <input id="max" name="max" type="checkbox" value="true"><input name="max" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Sum" style="display: none;"> <input id="sum" name="sum" type="checkbox" value="true"><input name="sum" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Int"> <input id="int" name="int" type="checkbox" value="true"><input name="int" type="hidden" value="false"> </span> </td>
</tr>
<tr class="webgrid3-row-style">
<td class="col1Width" style="display: none;"> <span id="SensorID">7</span> </td>
<td class="col1Width" style="display: none;"> <span id="DeviceID">1</span> </td>
<td class="col1Width" style="display: none;"> <span id="SensorType" class="SensorType">203</span> </td>
<td class="col2Width"> <span><label id="SensorName">Wind speed </label> </span> </td>
<td class="col1Width"><span class="Val"> <input id="val" name="val" type="checkbox" value="true"><input name="val" type="hidden" value="false"> </span></td>
<td class="col1Width"><span class="Min" style="display: none;"> <input id="min" name="min" type="checkbox" value="true"><input name="min" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Avg" style="display: none;"> <input id="avg" name="avg" type="checkbox" value="true"><input name="avg" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Max" style="display: none;"> <input id="max" name="max" type="checkbox" value="true"><input name="max" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Sum" style="display: none;"> <input id="sum" name="sum" type="checkbox" value="true"><input name="sum" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Int"> <input id="int" name="int" type="checkbox" value="true"><input name="int" type="hidden" value="false"> </span> </td>
</tr>
<tr class="webgrid3-alternating-row">
<td class="col1Width" style="display: none;"> <span id="SensorID">8</span> </td>
<td class="col1Width" style="display: none;"> <span id="DeviceID">1</span> </td>
<td class="col1Width" style="display: none;"> <span id="SensorType" class="SensorType">204</span> </td>
<td class="col2Width"> <span><label id="SensorName">Wind direction </label> </span> </td>
<td class="col1Width"><span class="Val"> <input id="val" name="val" type="checkbox" value="true"><input name="val" type="hidden" value="false"> </span></td>
<td class="col1Width"><span class="Min" style="display: none;"> <input id="min" name="min" type="checkbox" value="true"><input name="min" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Avg" style="display: none;"> <input id="avg" name="avg" type="checkbox" value="true"><input name="avg" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Max" style="display: none;"> <input id="max" name="max" type="checkbox" value="true"><input name="max" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Sum" style="display: none;"> <input id="sum" name="sum" type="checkbox" value="true"><input name="sum" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Int"> <input id="int" name="int" type="checkbox" value="true"><input name="int" type="hidden" value="false"> </span> </td>
</tr>
<tr class="webgrid3-row-style">
<td class="col1Width" style="display: none;"> <span id="SensorID">9</span> </td>
<td class="col1Width" style="display: none;"> <span id="DeviceID">1</span> </td>
<td class="col1Width" style="display: none;"> <span id="SensorType" class="SensorType">205</span> </td>
<td class="col2Width"> <span><label id="SensorName">Precipitation </label> </span> </td>
<td class="col1Width"><span class="Val"> <input id="val" name="val" type="checkbox" value="true"><input name="val" type="hidden" value="false"> </span></td>
<td class="col1Width"><span class="Min" style="display: none;"> <input id="min" name="min" type="checkbox" value="true"><input name="min" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Avg" style="display: none;"> <input id="avg" name="avg" type="checkbox" value="true"><input name="avg" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Max" style="display: none;"> <input id="max" name="max" type="checkbox" value="true"><input name="max" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Sum" style="display: none;"> <input id="sum" name="sum" type="checkbox" value="true"><input name="sum" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Int"> <input id="int" name="int" type="checkbox" value="true"><input name="int" type="hidden" value="false"> </span> </td>
</tr>
<tr class="webgrid3-alternating-row">
<td class="col1Width" style="display: none;"> <span id="SensorID">10</span> </td>
<td class="col1Width" style="display: none;"> <span id="DeviceID">1</span> </td>
<td class="col1Width" style="display: none;"> <span id="SensorType" class="SensorType">206</span> </td>
<td class="col2Width"> <span><label id="SensorName">Solar radiation </label> </span> </td>
<td class="col1Width"><span class="Val"> <input id="val" name="val" type="checkbox" value="true"><input name="val" type="hidden" value="false"> </span></td>
<td class="col1Width"><span class="Min" style="display: none;"> <input id="min" name="min" type="checkbox" value="true"><input name="min" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Avg" style="display: none;"> <input id="avg" name="avg" type="checkbox" value="true"><input name="avg" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Max" style="display: none;"> <input id="max" name="max" type="checkbox" value="true"><input name="max" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Sum" style="display: none;"> <input id="sum" name="sum" type="checkbox" value="true"><input name="sum" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Int"> <input id="int" name="int" type="checkbox" value="true"><input name="int" type="hidden" value="false"> </span> </td>
</tr>
<tr class="webgrid3-row-style">
<td class="col1Width" style="display: none;"> <span id="SensorID">51</span> </td>
<td class="col1Width" style="display: none;"> <span id="DeviceID">1</span> </td>
<td class="col1Width" style="display: none;"> <span id="SensorType" class="SensorType">20</span> </td>
<td class="col2Width"> <span><label id="SensorName">Battery </label> </span> </td>
<td class="col1Width"><span class="Val"> <input id="val" name="val" type="checkbox" value="true"><input name="val" type="hidden" value="false"> </span></td>
<td class="col1Width"><span class="Min"> <input id="min" name="min" type="checkbox" value="true"><input name="min" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Avg"> <input id="avg" name="avg" type="checkbox" value="true"><input name="avg" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Max"> <input id="max" name="max" type="checkbox" value="true"><input name="max" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Sum" style="display: none;"> <input id="sum" name="sum" type="checkbox" value="true"><input name="sum" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Int" style="display: none;"> <input id="int" name="int" type="checkbox" value="true"><input name="int" type="hidden" value="false"> </span> </td>
</tr>
<tr class="webgrid3-alternating-row">
<td class="col1Width" style="display: none;"> <span id="SensorID">56</span> </td>
<td class="col1Width" style="display: none;"> <span id="DeviceID">1</span> </td>
<td class="col1Width" style="display: none;"> <span id="SensorType" class="SensorType">101</span> </td>
<td class="col2Width"> <span><label id="SensorName">Leaf wetness drugi</label> </span> </td>
<td class="col1Width"><span class="Val"> <input id="val" name="val" type="checkbox" value="true"><input name="val" type="hidden" value="false"> </span></td>
<td class="col1Width"><span class="Min" style="display: none;"> <input id="min" name="min" type="checkbox" value="true"><input name="min" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Avg" style="display: none;"> <input id="avg" name="avg" type="checkbox" value="true"><input name="avg" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Max" style="display: none;"> <input id="max" name="max" type="checkbox" value="true"><input name="max" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Sum"> <input id="sum" name="sum" type="checkbox" value="true"><input name="sum" type="hidden" value="false"> </span> </td>
<td class="col1Width"> <span class="Int" style="display: none;"> <input id="int" name="int" type="checkbox" value="true"><input name="int" type="hidden" value="false"> </span> </td>
</tr>
</tbody>
所以我现在想要获取每行的每个复选框(总共有六个复选框)的每个值(即使它是假的)(可以是从零到任何数字,具体取决于有多少个 SensorID) (这是唯一的)DeviceID(每行都相同))。但我不知道如何迭代每一行。我尝试使用 FormCollection,但这对我来说不起作用,有人有任何其他建议可以帮助我吗?
public ActionResult InsertSensorsInExistingPredefineView(FormCollection sensorCollection)
{
foreach (var row in sensorCollection.AllKeys)
bool _val = sensorCollection["val"] != "false";
bool _min = sensorCollection["min"] != "false";
bool _avg = sensorCollection["avg"] != "false";
bool _max = sensorCollection["max"] != "false";
bool _sum = sensorCollection["sum"] != "false";
bool _int = sensorCollection["int"] != "false";
if (//some logic checking for at least one true value)
{
//save to some db table acording to sensorID....
}
}
return view;
}
我做了整个 != "false"事情,因为复选框以字符串形式返回值,就像如果选中则以“true,false”形式出现的字符串,如果未选中则以“false”形式返回的字符串。 我在这里一定做错了什么,我刚刚编辑了我的第一行(SensorID),认为它可以作为计数器,但我仍然在挣扎。
我不知道在这里要做什么,我是否有机会使用 Javascript/jQuery 完成我的任务,然后将结果发送到 Controller ?
我只是尝试看看它是否会迭代每一行并获取值:
<input type="submit" class="DoSomething" value="Do it" />
foreach (WebGridRow row in gridSensorChoose.Rows)
{
<script type="text/javascript">
$(function () {
$(".DoSomething").on("click", function () {
var tr = $(this).parents('tr:first');
var sensorID = tr.find(".SensorID").html();
var _val = tr.find(".Val").html();
var _min = tr.find(".Min").html();
var _avg = tr.find(".Avg").html();
var _max = tr.find(".Max").html();
var _sum = tr.find(".Sum").html();
var _int = tr.find(".Int").html();
})
if (_val == true || _min =! true || _avg == true || _max == true || _sum == true || _int == true ||){
//ajax send all vars to controller
}
//and now iterate through next row
})
</script>
也许我可以在java脚本中写出类似的东西,并在每次结束迭代时将其发送到 Controller ?然后它开始一个新的行,直到没有更多的行。
最佳答案
根据您的代码行,我发现您误解了某些内容
foreach (var row in sensorCollection.AllKeys)
{
}
sensorCollection 中的值不是行。它们是从 View 传递的字段。
您的 HTML 有很多同名的输入。举个例子:
<input id="val" name="val" type="checkbox" value="true">
sensorCollection.AllKeys
将包含“val”的多个条目 - 网格上的每一行都有一个条目。您将迭代每个值,然后忽略该值并再次检索该值。本质上是这样的
foreach (var row in sensorCollection.AllKeys)
{
bool _val = sensorCollection["val"] != "false";
bool _min = sensorCollection["min"] != "false";
bool _avg = sensorCollection["avg"] != "false";
bool _max = sensorCollection["max"] != "false";
bool _sum = sensorCollection["sum"] != "false";
bool _int = sensorCollection["int"] != "false";
}
相当于:
for(int i = 0; i < number_of_rows; i++)
{
bool _val = sensorCollection["val"] != "false";
bool _min = sensorCollection["min"] != "false";
bool _avg = sensorCollection["avg"] != "false";
bool _max = sensorCollection["max"] != "false";
bool _sum = sensorCollection["sum"] != "false";
bool _int = sensorCollection["int"] != "false";
}
看看i
在那里是如何不相关的? row
也是如此。您没有引用它,因此这些值将始终相同 - 可能是网格上第一行的值。
你需要做这样的事情
// find the number of values for "val" in the collection
// build a for loop that iterates over the collection
for(int i = 0; i < sensorCollection.AllKeys.Where(k => k == "val").Count(); i++)
{
// get the nth of each key, where n is the instance of "val"
bool _val = sensorCollection.AllKeys.Where(k => k == "val")[i] != "false";
// handle the other values (I'm too lazy to type them out)
// save out the data
}
好的,我构建了一个新的 MVC 应用程序并复制了您的网格和回发,这就是我发现的内容。
首先,sensorCollection.AllKeys中有6个值 - 每列一个值(val,min,avg,max,sum,int)
其次,由于某种原因,数据被编码为串联字符串。因此,如果您勾选第一个 val 复选框,则 sensorCollection[0] = "true,false,false,false,false,false,false,false,false,false,false,false,false"
我没想到会这样,这有点奇怪,但我们会解决它。这段代码应该可以解决你的问题:
public ActionResult InsertSensorsInExistingPredefineView(FormCollection sensorCollection)
{
bool[] vals = sensorCollection["val"].Split(',').Select(x => Convert.ToBoolean(x)).ToArray();
bool[] mins = sensorCollection["min"].Split(',').Select(x => Convert.ToBoolean(x)).ToArray();
bool[] avgs = sensorCollection["avg"].Split(',').Select(x => Convert.ToBoolean(x)).ToArray();
bool[] maxs = sensorCollection["max"].Split(',').Select(x => Convert.ToBoolean(x)).ToArray();
bool[] sums = sensorCollection["sum"].Split(',').Select(x => Convert.ToBoolean(x)).ToArray();
bool[] ints = sensorCollection["int"].Split(',').Select(x => Convert.ToBoolean(x)).ToArray();
for (int i = 0; i < vals.Count(); i++)
{
// your first row, "Soil Temperature":
bool val = vals[i];
bool min = mins[i];
// etc
}
}
关于javascript - 如何从 MVC 项目中的每个表行获取每个值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27295444/
我有一个 html 格式的表单: 我需要得到 JavaScript在value input 字段执行,但只能通过表单的 submit .原因是页面是一个模板所以我不控制它(不能有
我管理的论坛是托管软件,因此我无法访问源代码,我只能向页面添加 JavaScript 来实现我需要完成的任务。 我正在尝试用超链接替换所有页面上某些文本关键字的第一个实例。我还根据国家/地区代码对这些
我正在使用 JS 打开新页面并将 HTML 代码写入其中,但是当我尝试使用 document.write() 在新页面中编写 JS 时功能不起作用。显然,一旦看到 ,主 JS 就会关闭。用于即将打开的
提问不是为了解决问题,提问是为了更好地理解系统 专家!我知道每当你将 javascript 代码输入 javascript 引擎时,它会立即由 javascript 引擎执行。由于没有看过Engi
我在一个文件夹中有两个 javascript 文件。我想将一个变量的 javascript 文件传递到另一个。我应该使用什么程序? 最佳答案 window.postMessage用于跨文档消息。使
我有一个练习,我需要输入两个输入并检查它们是否都等于一个。 如果是 console.log 正则 console.log false 我试过这样的事情: function isPositive(fir
我正在做一个Web应用程序,计划允许其他网站(客户端)在其页面上嵌入以下javascript: 我的网络应用程序位于 http://example.org 。 我不能假设客户端网站的页面有 JQue
目前我正在使用三个外部 JS 文件。 我喜欢将所有三个 JS 文件合而为一。 尽一切可能。我创建 aio.js 并在 aio.js 中 src="https://code.jquery.com/
我有例如像这样的数组: var myArray = []; var item1 = { start: '08:00', end: '09:30' } var item2 = {
所以我正在制作一个 Chrome 扩展,它使用我制作的一些 TamperMonkey 脚本。我想要一个“主”javascript 文件,您可以在其中包含并执行其他脚本。我很擅长使用以下行将其他 jav
我有 A、B html 和 A、B javascript 文件。 并且,如何将 A JavaScript 中使用的全局变量直接移动到 B JavaScript 中? 示例 JavaScript) va
我需要将以下整个代码放入名为 activate.js 的 JavaScript 中。你能告诉我怎么做吗? var int = new int({ seconds: 30, mark
我已经为我的 .net Web 应用程序创建了母版页 EXAMPLE1.Master。他们的 I 将值存储在 JavaScript 变量中。我想在另一个 JS 文件中检索该变量。 示例1.大师:-
是否有任何库可以用来转换这样的代码: function () { var a = 1; } 像这样的代码: function () { var a = 1; } 在我的浏览器中。因为我在 Gi
我收到语法缺失 ) 错误 $(document).ready(function changeText() { var p = document.getElementById('bidp
我正在制作进度条。它有一个标签。我想调整某个脚本完成的标签。在找到可能的解决方案的一些答案后,我想出了以下脚本。第一个启动并按预期工作。然而,第二个却没有。它出什么问题了?代码如下: HTML:
这里有一个很简单的问题,我简单的头脑无法回答:为什么我在外部库中加载时,下面的匿名和onload函数没有运行?我错过了一些非常非常基本的东西。 Library.js 只有一行:console.log(
我知道 javascript 是一种客户端语言,但如果实际代码中嵌入的 javascript 代码以某种方式与在控制台上运行的代码不同,我会尝试找到答案。让我用一个例子来解释它: 我想创建一个像 Mi
我如何将这个内联 javascript 更改为 Unobtrusive JavaScript? 谢谢! 感谢您的回答,但它不起作用。我的代码是: PHP js文件 document.getElem
我正在寻找将简单的 JavaScript 对象“转储”到动态生成的 JavaScript 源代码中的最优雅的方法。 目的:假设我们有 node.js 服务器生成 HTML。我们在服务器端有一个对象x。
我是一名优秀的程序员,十分优秀!