Link to home
Start Free TrialLog in
Avatar of dkim18
dkim18

asked on

A way to insert a value into a SqlDataSource??

Hi,

I am inserting a new record from the detailsview of insert mode.
I have a SqlDataSource to insert a new record.
If possible, I would like to insert a user's value coming from the WindowsIdentity.GetCurrentUser(),Name.
<asp:SqlDataSource ...
InsertCommand="Insert into table(type, title,name) values(@type,@title,'admin')
....</asp:SqlDataSource>

Instead of 'admin', I would like to grab the userID using WindowsIdentity.GetCurrentUser(),Name.
 and attach to that sqldatasource.
ASKER CERTIFIED SOLUTION
Avatar of carlnorrbom
carlnorrbom
Flag of Sweden image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dkim18
dkim18

ASKER

Thanks much Carl.

THat SessionParameter worked for me.
I don't know if that is proper way of doing thing but for now i think i will use that.
Hi,

Well, as far as I know there is no other, more "proper" way of doing it. You need to to pass the value from the user context to a variable which can be consumed by the datasource, then you are limited to a number possible choices, using the SessionParameter is probably the easiest, most "clean" implementation.

/Carl.