USE LOOP TO SET PROPERTY OF ALL RADGRIDS IN WEBFORM?

Jeet Verma

Total Post:110

Points:776
Posted by  Jeet Verma
C# 
C#
 666  View(s)
Ratings:
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.

  1. Sumit Kesarwani

    Post:378

    Points:2694
    Re: Use loop to set property of all RadGrids in webform?

    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));

        }

    }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!