0

我有这个代码:

<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>

后面的代码:

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

Convert.ToDecimal(Request.Form[(int)col.CID]);不返回正确的值。我的页面上有大约 26 个输入范围控件,但在获得compVal第 8 个输入后,炸弹背后的代码。有任何想法吗?

4

0 回答 0