Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Without your exact markup we can only guess the solution here.</p> <p>You must be using another container to wrap your controls inside your ItemTemplate in the ListView, something like a Panel or other containers. When you get the Controls on the list view item you actually get the warping container and not its children(labels, dropdowns etc.) One solution to this is something like:</p> <pre><code>foreach (ListViewItem item in lsvTSEntry.Items) { item.FindControl("myLabel").Visible = false; item.FindControl("myDropdownList").Visible = false; } </code></pre> <p>Basically you try to find the controls by id and hide them. Notice there is no error checking there so you could get a NullReferenceException if FindControl returns null.</p> <p>In case you have nested containers in your ItemTemplate and you want to hide all the labels and dropdowns regardless of where they are you can implement your own recursive FindControl that will look like:</p> <pre><code>private Control FindControlRecursive(Control rootControl, string controlId) { if (rootControl.ID == controlId) { return rootControl; } foreach (Control controlToSearch in rootControl.Controls) { Control controlToReturn = FindControlRecursive(controlToSearch, controlId); if (controlToReturn != null) { return controlToReturn; } } return null; } </code></pre> <p>Not the most elegant but.... You can change this to take an array of Id's of course for speed purposes. Based on this of course you can implement the search by control type which instead of taking a controlId as a parameter will take the types of controls to find. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload