What is of this.Page.Controls.Add method in ASP.Net

Last Reply on May 08, 2013 01:49 AM By Mudassar

Posted on May 08, 2013 01:48 AM
sir what is the use of 
in the following code.
  protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        SqlDataSource SqlDataSource1 = new SqlDataSource();
        SqlDataSource1.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
        SqlDataSource1.SelectCommand = "SELECT * FROM users WHERE ElectionId ='" + this.TextBox1.Text.Trim() + "'";
        this.GridView1.DataSource = SqlDataSource1;
        this.GridView1.Visible = true;


Posted on May 08, 2013 01:49 AM

In order to use any control it must be added to the Page otherwise you won't be able to use it.

Since we are adding dynamic SQL DataSource hence it is required