Username in datagrid
-
Hi all, I have this problem could I get some help? This code works on a plain webform and I get user name: string DomainUser = System.Security.Principal.WindowsIdentity.GetCurrent().Name.Replace("\\","/"); System.DirectoryServices.DirectoryEntry ADEntry = new System.DirectoryServices.DirectoryEntry("WinNT://"+DomainUser); Response.Write(ADEntry.Properties["FullName"].Value.ToString()); But When I try it on a datagrid it does not work why is it so? where would I be going wrong? myCommand.Parameters.Add(new SqlParameter("@Name",SqlDbType.Text)); myCommand.Parameters["@Name"].Value = System.Security.Principal.WindowsIdentity.GetCurrent().Name.Replace("\\","/"); System.DirectoryServices.DirectoryEntry ADEntry = new System.DirectoryServices.DirectoryEntry("WinNT://"+st6); Response.Write(ADEntry.Properties["FullName"].Value.ToString()); Thanks.