sir what is the use of
this.Page.Controls.Add(SqlDataSource1);
in the following code.
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
SqlDataSource SqlDataSource1 = new SqlDataSource();
this.Page.Controls.Add(SqlDataSource1);
SqlDataSource1.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlDataSource1.SelectCommand = "SELECT * FROM users WHERE ElectionId ='" + this.TextBox1.Text.Trim() + "'";
this.GridView1.DataSource = SqlDataSource1;
this.GridView1.DataBind();
this.GridView1.Visible = true;
}