I have an asp.net application with a form that captures some information that is stored in a MS SQL database. I would like to know who creates each record. I currently have an asp:textbox that captures the current user with:
creator_txt.Text = System.Web.HttpContext.Current.User.Identity.Name;
Then I use that text field in a SqlCommand and insert it into a MS SQL Server table using:
SqlCommand new_record_cmd = new SqlCommand("Insert Into tbl(record_nm, creator) Values @record_nm, @creator)))", lcms_cnxn);
It all works just fine, but I would like this field to be hidden - it doesn't need to be visible in the form.
Do I need this text field at all?
If yes, how do I hide the field from the layout and still pass the value of creator_txt to the database?
If not, how do I pass the current user to @creator without using the text field?
I hope this makes sense. Please ask questions if it's not clear.
I am using Visual Studio 2012, SQL Server Management Studio 2012, asp.net and c#.