title: Display table from code behind
body: <p>I have a function in my program that prints a string consisting of a table to the page.</p>
  
  <pre><code>getWhileLoopData(){          
          string htmlStr = "";
          SqlConnection thisConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);     
          SqlCommand thisCommand = thisConnection.CreateCommand();       
          thisCommand.CommandText = "SELECT * from events";      
          thisConnection.Open();      
          SqlDataReader reader = thisCommand.ExecuteReader();      
          while (reader.Read()){      
              int room_id = reader.GetInt32(0);
              string title = reader.GetString(1);                
              htmlStr += "&lt;tr&gt;&lt;td&gt;" + title + "&lt;/td&gt;&lt;/tr&gt;";                        
          }      
          thisConnection.Close();      
          return htmlStr;
  }
  </code></pre>
  
  <p>In the .aspx page I call it by <code>&lt;%=getWhileLoopData()%&gt;</code> It works. 
  But the problem is when I open the page in the <code>page_load(object sender, EventArgs e)</code> function I have something similar, it appends table values to a string. </p>
  
  <p>How do I make the string from the page_load() function print to the screen?</p>