Home > DeveloperSection > Forums > Use loop to set property of all RadGrids in webform?
Jeet Verma
Jeet Verma

Total Post:110

Points:776
Posted on    September-29-2014 12:52 AM

 C# C# 
Ratings:


 1 Reply(s)
 477  View(s)
Rate this:

I have several radgrids in my webform and I want to set all the visible property to false without having to specify the control name.

 

How can I do this with a loop?

 

Thanks.



Sumit Kesarwani

Total Post:378

Points:2694
Posted on    September-29-2014 1:04 AM

Hi Jeet, 

try this:

protected void Page_Load(object sender, EventArgs e)

{

    for (int i = 0; i < form1.Controls.Count; i++)

    {

        if ((form1.Controls[i]) is RadGrid)

            Response.Write(string.Format("found a grid with ID: {0}<br />", form1.Controls[i].ClientID));

    }

}


Don't want to miss updates? Please click the below button!

Follow MindStick