c# - Set session variable from SqlDataSource -


i trying set session variable return of sqldatasource. able set value label/textbox/hidden field, cannot seem set session variable.

i using page_load function try , set them.

protected void page_load(object sender, eventargs e) {                 this.session["username"] = user.identity.name;         this.session["emplid"] = eval("emplid"); } 

i have sqldatasource:

<asp:sqldatasource id="sqlgetemplid" runat="server"              connectionstring="<%$ connectionstrings:mafapp %>"              selectcommand="select distinct emplid, status employees (intlogin = @username) , (dept = n'eng' or dept = n'is') , (status = n'active')">     <selectparameters>         <asp:sessionparameter name="username" sessionfield="username" />     </selectparameters> </asp:sqldatasource> 

an alternative doing if user.identity.name

string fullusername = null; using (principalcontext pc = new principalcontext(contexttype.domain)) {     using (userprincipal user = userprincipal.findbyidentity(pc,user.identity.name))     {         if (user != null)         {             fullusername = user.displayname;//this can ever          }     } } 

Comments

Popular posts from this blog

javascript - How to synchronize the Three.js and HTML/SVG coordinate systems (especially w.r.t. the y-axis)? -

javascript - How do I find how many occurences are there of a highlighted string, and which occurence is it? -

java - Reading data from multiple zip files and combining them to one -