索引超出了数组的范围

时间:2019-10-07 07:09:18

标签: c# asp.net for-loop dbcontext

我试图保存一个遍历10列的列表,并且我的代码抛出System.IndexOutOfRangeException。我经历了所有其他解决方案,他们没有解决我的问题。内部异常具有NULL。

for (int i = 1; i <= 9; i++)
{
    txtIndicator = (TextBox)this.UpdatePanel1.FindControl("txtIndicator" + i);
    if (manipType.Equals("add"))
    {
        try
        {
            Databases.WeeklySurveillance iws = new Databases.WeeklySurveillance()
            {
                WeekEnding = DateTime.Parse(tmpMondayDate),
                FacilityCode = Session["facility"].ToString().Split(":".ToCharArray())[0],
                AgeGroup = iwsDataItems[i - 1].AgeGroup,
                Condition = iwsDataItems[i - 1].Condition,
                Position = i,
                Batch = 2019,
                Total = int.Parse(txtIndicator.Text),
                Description = Session["facility"].ToString().Split(":".ToCharArray())[1].Trim(),
                DateStamp = DateTime.Now
            };
            healthDC.WeeklySurveillances.Add(iws);
        }
    }
}

0 个答案:

没有答案