Return to Snippet

Revision: 24404
at March 1, 2010 22:09 by the_menace


Updated Code
// #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;
}

Revision: 24403
at March 1, 2010 12:14 by the_menace


Initial Code
// 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>");
}

// Databound (level 1 == index)
for (int i = 0; i < e.Item.Controls.Count; i++)
{
	Response.Write(e.Item.Controls[i].ID + "<br>");
}

Initial URL


Initial Description
Loop through the ListView Control within 2nd level collection. 2nd level means it's within another control (ie table html generic control).

Initial Title
ASP.NET - Loop through the ListView Control.

Initial Tags
c, aspnet

Initial Language
C#