Cannot apply indexing with [] to an expression of

2019-07-29 23:15发布

I am getting Error 'Cannot apply indexing with [] to an expression of type 'ISet''

for this code snippet

foreach (GridViewRow grv in customTableDataList.UniGrid.GridView.Rows)
{
  if (grv != null)
  {
    if (null != grv.FindControl(ItemCheckBoxID) && ((CheckBox)grv.FindControl(ItemCheckBoxID)).Checked)
    {
      //At this line I am getting error.
      itemIds += customTableDataList.UniGrid.ActionsID[rowCounter] + ", ";  
    }
    rowCounter++;
  }
}

Can anyone give some more details to resolve this.

1条回答
仙女界的扛把子
2楼-- · 2019-07-29 23:37

Add new using:

System.Linq;

and change

foreach (GridViewRow grv in customTableDataList.UniGrid.GridView.Rows)
{
  if (grv != null)
  {
    if (null != grv.FindControl(ItemCheckBoxID) && ((CheckBox)grv.FindControl(ItemCheckBoxID)).Checked)
    {
      itemIds += customTableDataList.UniGrid.ActionsID.ToArray()[rowCounter] + ", ";
    }
    rowCounter++;
  }
}
查看更多
登录 后发表回答