Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/317.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# C“Request.Form[";ID";]未返回正确的”;输入类型=范围;价值_C#_Asp.net_Range - Fatal编程技术网

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);
    }
}