C# C“Request.Form[";ID";]未返回正确的”;输入类型=范围;价值
我有以下代码:C# C“Request.Form[";ID";]未返回正确的”;输入类型=范围;价值,c#,asp.net,range,C#,Asp.net,Range,我有以下代码: <div> <asp:DataList ID="dlRange" runat="server" RepeatDirection="Vertical" RepeatLayout="Flow" OnItemDataBound="dlRange_ItemDataBound"> <ItemTemplate> <hr>
<div>
<asp:DataList ID="dlRange" runat="server" RepeatDirection="Vertical" RepeatLayout="Flow"
OnItemDataBound="dlRange_ItemDataBound">
<ItemTemplate>
<hr>
<h2>
<%# Eval("COMMITEENAME")%>
</h2>
<asp:DataList ID="dlComp" runat="server" RepeatDirection="Vertical" RepeatLayout="Flow">
<ItemTemplate>
<label for='<%#"comp" + Eval("CID")%>'>
<%# Eval("NAME")%></label>
<input id='<%#"comp" + Eval("CID")%>' type="range" pattern="[0-9]*" name='<%#"comp" + Eval("CID")%>'
min="0" max="10" data-highlight="true" value="" data-show-value="true" data-popup-enabled="true" />
</ItemTemplate>
</asp:DataList>
</ItemTemplate>
</asp:DataList>
<br />
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click"
data-theme="b" />
</div>
Convert.ToDecimal(Request.Form[(int)col.CID])代码>未返回正确的值。我的页面上有大约26个输入范围控件,但在第8次输入时,在获得compVal
后,隐藏的代码会爆炸。有什么想法吗?当它“轰炸”时,会产生什么错误?没有错误,它只是退出for循环,不会命中下一行代码。在VS中,ctrl+alt+e
将弹出一个异常对话框。选中公共语言运行时异常
上的抛出
框,然后再次运行它。如果它正在消亡,那么一定有一个关于为什么会这样的错误。
protected void btnSubmit_Click(object sender, EventArgs e)
{
using (BOTEntities context = new BOTEntities())
{
string memberID = Request.Cookies["BOTDAT"]["PersonId"];
var comps = context.COMPETENCies.OrderBy(o => o.CID);
DateTime date = DateTime.Now;
foreach (var col in comps)
{
COMPVALUE newCompVal = new COMPVALUE();
newCompVal.CID = col.CID;
newCompVal.C_DATE = date;
newCompVal.MEMBERID = memberID;
decimal compVal = Request.Form["comp" + col.CID] == "" ? 0 : Convert.ToDecimal(Request.Form[(int)col.CID]);
newCompVal.VALUE = compVal;
context.COMPVALUEs.Add(newCompVal);
}
int result = context.SaveChanges();
System.Diagnostics.Debug.WriteLine("Added to CompValue" + result);
}
}