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

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -