lundi 13 juillet 2015

Check Box list collection was modified enumeration operation may not execute

I have seen lots of examples in this Question, but till not concluded. and i tried with all these EXAMPLES. I am trying to remove empty check box list which are binding from data base.

DataSet ds4 = getCheckBox(ViewState["id"].ToString());
        chkEnvironment.DataSource = ds4;
        chkEnvironment.DataTextField = "Environment";
        chkEnvironment.DataValueField = "Environmentid";
        chkEnvironment.DataBind();

But it is showing empty check boxes in my page. how to do it

protected void chkEnvironment_DataBound(object sender, EventArgs e)
    {
        foreach (ListItem item in chkEnvironment.Items)
        {
            if (item.Value == "NULL")
            {
                chkEnvironment.Items.Remove(item);
            }
        }
    }




Aucun commentaire:

Enregistrer un commentaire