title: How can I bind a gridview to datasource with dynamic WHERE clause?
body: <p>I am using Visual Basic for ASP. NET</p>
  
  <p>I know how to populate a gridview with data using only code behind, like this</p>
  
  <pre><code>Dim ds as new datasourse
  Dim da as new dataadaptor
  Dim con as new SqlConnection
  Dim cmd as new SqlCommand
  ... 
  Cmd = "select ticketID, problem_text from problems where support_engineer = " &amp; Session("Logged_in_user_id")
  ... 
  Gridview1.Datasource = ds
  Gridview1.Datasources. DataBind
  </code></pre>
  
  <p>And that works fines,  but my question is: how can i drag and drop a gridview control, and using only the wizard to populate the gridview in design time, how can i define the SELECT statement to only select rows that are related to the logged in user id? See the sql statement above, it uses a session variable that i create in Page_Load event, but how can i use the same logic in design mode? (i don't want to modify the datasource control in code behind)</p>
  
  <p>I looked in youtube and google, and this sites,  but all results are simply showing me how to populate the gridview with all rows or with a static condition, not a dynamic one like the one i demonestrated.</p>
  
  <p>Any help is highly appreciated</p>