Thursday, March 22, 2012

Looping in ASP.NET

Hi,

How to work with For Loop to display the values in .aspx page dynamically ? E.g

for (i=0; i=100; i++)

How to display the i value in a Label control in a .aspx file each time when i value is changed?

Thanks

Kaushik

Check this please;
private void CallControls(System.Web.UI.Control p)
{
foreach ( Control ctrlMain in p.Controls )
{
if (ctrlMain.ToString().Equals("System.Web.UI.WebControls.Button") )
{
Button b;
b =(Button)FindControl(ctrlMain.ID);
b.Text = "1";
}
if ( ctrlMain.HasControls() )
{
/* Recursive Call */
CallControls(ctrlMain);
}
}
}
that was done for a button, change it to work with a label.
regards

0 comments:

Post a Comment