title: Set session variable from SqlDataSource
body: <p>I am trying to set some session variable from the return of a <code>SqlDataSource</code>. I am able to set the value to a label/textbox/hidden field, but I cannot seem to set the session variable. </p>
  
  <p>I am using a <code>page_load</code> function to try and set them.</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {        
          this.Session["UserName"] = User.Identity.Name;
          this.Session["EmplID"] = Eval("EmplID");
  }
  </code></pre>
  
  <p>I have a <code>SqlDataSource</code>:</p>
  
  <pre><code>&lt;asp:SqlDataSource ID="SQLGetEmplID" runat="server" 
              ConnectionString="&lt;%$ ConnectionStrings:MAFapp %&gt;" 
              SelectCommand="SELECT DISTINCT EmplID, Status FROM Employees WHERE (intLogin = @UserName) AND (Dept = N'Eng' OR Dept = N'IS') AND (Status = N'Active')"&gt;
      &lt;SelectParameters&gt;
          &lt;asp:SessionParameter Name="UserName" SessionField="UserName" /&gt;
      &lt;/SelectParameters&gt;
  &lt;/asp:SqlDataSource&gt;
  </code></pre>