mercredi 20 janvier 2021

How can I select all the elements of a listbox by marking a checkbox?

I have a checkbox, I want that when it is checked selected all the elements of a list (which its elements are loaded dynamically) and when unchecking it all are deselected. I know that I have to program inside the checkedchanged event but I can't find the property or method to select all the elements of the list. I am working on asp.net, however I must not use javascript.

        private void chkTodos_CheckedChanged(object sender, EventArgs e)
        {

              for (int i = 0; i < milista.Item.Count; i++)
              {---------------------------}

              if (!chkTodo.Checked)
              {
                ----
              }
        }

Note: The version of .net I work with is very old. So some properties of the listbox like setSelected don't work.




Aucun commentaire:

Enregistrer un commentaire