/ Published in: C#
Loop through the ListView Control within 2nd level collection. 2nd level means it's within another control (ie table html generic control).
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// #1 - Loop through the ListView control (level 1 == index) for (int i = 0; i < ListView1.Controls[0].Controls[1].Controls.Count; i++) { Response.Write(ListView1.Controls[0].Controls[1].Controls[i] + "<br>"); } // #2 - Databound (level 1 == index) for (int i = 0; i < e.Item.Controls.Count; i++) { Response.Write(e.Item.Controls[i].ID + "<br>"); } // #3 - Iterate through each row collection for (int i = 0; i < ListView1.Items.Count + 1; i++) { // Each control on a row Response.Write(ListView1.Controls[0].Controls[1].Controls[i] + "<br>"); // Control collection per row ControlCollection c = ListView1.Controls[0].Controls[i].Controls; }