title: adding a data source to the gridview dynamically in C#
body: <p>Here i have tried to do bind the gridview as per the selection in the checkboxlist.
  I'm getting only blank page when its executed. can any one specify what's the mistake?</p>
  
  <pre><code>protected void Button1_Click(object sender, EventArgs e)
  {
  String query = "Select Proj_id,Proj_name,Front_end,Back_end from Proj_details where Front_end = 'Android'";
  String[] frontend ={ "Android", "Asp", "Asp.net", "C#.net", "J2EE", "Java", "Matlab", "NS2", "PHP", "VB", "VB.net" };
  try
  {
  for (int i = 0; i &lt;= CheckBoxList1.Items.Count; i++)
  {
  if (CheckBoxList1.Items[i].Selected)
  query = query.Insert(query.Length, frontend[i] + "','");
  }
  
  con.Open();
  query = query.Remove(query.Length - 1);
  query = query.Remove(query.Length - 1);
  query = query.Insert(query.Length, ")");
  SqlDataAdapter sqlada = new SqlDataAdapter(query, con);
  DataSet ds = new DataSet();
  sqlada.Fill(ds, "Proj_details");
  
  
  gv_search_project.DataSource = ds.Tables[0];
  gv_search_project.DataBind();
  
  
  
  }
  catch (Exception ex)
  {
  
  }
  finally
  {
  
  Label1.Text = query.ToString();
  }
  
  } 
  </code></pre>