how do i insert userid in formview
how do i insert userid in formview
am 15.01.2008 17:09:29 von Jim
I have created an insert FormView. There are three inputs to the database:
1. RestarurantId - automatically done
2. RestaurantUserId - Id of user that is logged in and inserts the record
3. RestaruantInfo - text information
The form below will insert the RestaurantId and the RestaurantInfo but for
the life of me, I can't figure how to get the UserId of the person logged
in. I have read the articles on aspnet.4guysfromrolla.com, but I can't
figure out how to make it work on my form.
Can someone show me the code I need to put in to make this work.
I'm using DotNet 3.5 and SQL Server 2005.
Thank you!!!!
---- Start of page code ---
<%@ Page Language="VB" %>
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Untitled Page
---- End of page code ---
Re: how do i insert userid in formview
am 15.01.2008 17:41:05 von Eliyahu Goldin
User.Identity.Name will give you user name. What do you mean by UserId?
--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Jim" wrote in message
news:Ot9fCE5VIHA.3400@TK2MSFTNGP03.phx.gbl...
>I have created an insert FormView. There are three inputs to the database:
> 1. RestarurantId - automatically done
> 2. RestaurantUserId - Id of user that is logged in and inserts the record
> 3. RestaruantInfo - text information
>
> The form below will insert the RestaurantId and the RestaurantInfo but for
> the life of me, I can't figure how to get the UserId of the person logged
> in. I have read the articles on aspnet.4guysfromrolla.com, but I can't
> figure out how to make it work on my form.
>
> Can someone show me the code I need to put in to make this work.
> I'm using DotNet 3.5 and SQL Server 2005.
>
> Thank you!!!!
>
>
> ---- Start of page code ---
>
> <%@ Page Language="VB" %>
>
>
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>
>
>
>
>
> Untitled Page
>
>
>
>
>
>
> ---- End of page code ---
>
>
Re: how do i insert userid in formview
am 15.01.2008 17:55:28 von Jim
I want the UserID for the user that is stored in the dbo.aspnet_Users table
to be inserted. This will identify the user with the record.
I don't know how to use the User.Identity.Name you listed. Can you show me
in my code what to do?
Thanks.
"Eliyahu Goldin" wrote in
message news:OO4OHW5VIHA.5340@TK2MSFTNGP06.phx.gbl...
> User.Identity.Name will give you user name. What do you mean by UserId?
>
> --
> Eliyahu Goldin,
> Software Developer
> Microsoft MVP [ASP.NET]
> http://msmvps.com/blogs/egoldin
> http://usableasp.net
>
>
> "Jim" wrote in message
> news:Ot9fCE5VIHA.3400@TK2MSFTNGP03.phx.gbl...
>>I have created an insert FormView. There are three inputs to the
>>database:
>> 1. RestarurantId - automatically done
>> 2. RestaurantUserId - Id of user that is logged in and inserts the record
>> 3. RestaruantInfo - text information
>>
>> The form below will insert the RestaurantId and the RestaurantInfo but
>> for the life of me, I can't figure how to get the UserId of the person
>> logged in. I have read the articles on aspnet.4guysfromrolla.com, but I
>> can't figure out how to make it work on my form.
>>
>> Can someone show me the code I need to put in to make this work.
>> I'm using DotNet 3.5 and SQL Server 2005.
>>
>> Thank you!!!!
>>
>>
>> ---- Start of page code ---
>>
>> <%@ Page Language="VB" %>
>>
>>
>> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>>
>>
>>
>>
>>
>> Untitled Page
>>
>>
>>
>>
>>
>>
>> ---- End of page code ---
>>
>>
>
>
Re: how do i insert userid in formview
am 15.01.2008 18:16:33 von Eliyahu Goldin
1.Add to the
in the datasource and add UserId to the insert sql..
2. Handle Inserting event for the datasource. In the event call
User.Identity.Name to get user name and then Membership.GetUser
(userName).ProviderUserKey to get user id.
3. In the same Inserting event, Locate the @UserId parameter in the insert
parameter collection as e.Command.Parameters["@UserId"]. Set it's value to
the user id obtained on step 2.
--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Jim" wrote in message
news:Oa4xud5VIHA.5448@TK2MSFTNGP04.phx.gbl...
>I want the UserID for the user that is stored in the dbo.aspnet_Users table
>to be inserted. This will identify the user with the record.
> I don't know how to use the User.Identity.Name you listed. Can you show
> me in my code what to do?
> Thanks.
>
> "Eliyahu Goldin" wrote in
> message news:OO4OHW5VIHA.5340@TK2MSFTNGP06.phx.gbl...
>> User.Identity.Name will give you user name. What do you mean by UserId?
>>
>> --
>> Eliyahu Goldin,
>> Software Developer
>> Microsoft MVP [ASP.NET]
>> http://msmvps.com/blogs/egoldin
>> http://usableasp.net
>>
>>
>> "Jim" wrote in message
>> news:Ot9fCE5VIHA.3400@TK2MSFTNGP03.phx.gbl...
>>>I have created an insert FormView. There are three inputs to the
>>>database:
>>> 1. RestarurantId - automatically done
>>> 2. RestaurantUserId - Id of user that is logged in and inserts the
>>> record
>>> 3. RestaruantInfo - text information
>>>
>>> The form below will insert the RestaurantId and the RestaurantInfo but
>>> for the life of me, I can't figure how to get the UserId of the person
>>> logged in. I have read the articles on aspnet.4guysfromrolla.com, but I
>>> can't figure out how to make it work on my form.
>>>
>>> Can someone show me the code I need to put in to make this work.
>>> I'm using DotNet 3.5 and SQL Server 2005.
>>>
>>> Thank you!!!!
>>>
>>>
>>> ---- Start of page code ---
>>>
>>> <%@ Page Language="VB" %>
>>>
>>>
>>> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>>>
>>>
>>>
>>>
>>>
>>> Untitled Page
>>>
>>>
>>>
>>>
>>>
>>>
>>> ---- End of page code ---
>>>
>>>
>>
>>
>
>
Re: how do i insert userid in formview
am 15.01.2008 18:52:57 von Jim
I understood number 1, but not 2 and 3. I'm thinkng 2 and 3 have to do with
the script and that I have no idea past what I wrote. Here is what I put in
for all the code. Can you help with it from what you wrote.
Thanks.
..
-- Start of Code ---
<%@ Page Language="VB" %>
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Untitled Page
--- End of Code ---
"Eliyahu Goldin" wrote in
message news:ugRm8p5VIHA.4880@TK2MSFTNGP03.phx.gbl...
> 1.Add to the
> in the datasource and add UserId to the insert sql..
>
> 2. Handle Inserting event for the datasource. In the event call
> User.Identity.Name to get user name and then Membership.GetUser
> (userName).ProviderUserKey to get user id.
>
> 3. In the same Inserting event, Locate the @UserId parameter in the insert
> parameter collection as e.Command.Parameters["@UserId"]. Set it's value to
> the user id obtained on step 2.
>
> --
> Eliyahu Goldin,
> Software Developer
> Microsoft MVP [ASP.NET]
> http://msmvps.com/blogs/egoldin
> http://usableasp.net
>
Re: how do i insert userid in formview
am 16.01.2008 11:21:36 von Eliyahu Goldin
You already have a server script for FormView1_InsertButtonClick. Add there
an event handler for SqlDataSource1_Insering. Look up a bit msdn topics on
SqlDataSource event. There is nothing special in handling them, it is just a
regular programming task. You will face hundreds of them as you proceed with
asp.net development.
--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Jim" wrote in message
news:OWE5295VIHA.4868@TK2MSFTNGP03.phx.gbl...
>I understood number 1, but not 2 and 3. I'm thinkng 2 and 3 have to do
>with the script and that I have no idea past what I wrote. Here is what I
>put in for all the code. Can you help with it from what you wrote.
> Thanks.
> .
> -- Start of Code ---
> <%@ Page Language="VB" %>
>
>
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>
>
>
>
>
> Untitled Page
>
>
>
>
>
>
> --- End of Code ---
>
> "Eliyahu Goldin" wrote in
> message news:ugRm8p5VIHA.4880@TK2MSFTNGP03.phx.gbl...
>> 1.Add to the
>> in the datasource and add UserId to the insert sql..
>>
>> 2. Handle Inserting event for the datasource. In the event call
>> User.Identity.Name to get user name and then Membership.GetUser
>> (userName).ProviderUserKey to get user id.
>>
>> 3. In the same Inserting event, Locate the @UserId parameter in the
>> insert parameter collection as e.Command.Parameters["@UserId"]. Set it's
>> value to the user id obtained on step 2.
>>
>> --
>> Eliyahu Goldin,
>> Software Developer
>> Microsoft MVP [ASP.NET]
>> http://msmvps.com/blogs/egoldin
>> http://usableasp.net
>>
>
>
Re: how do i insert userid in formview
am 16.01.2008 19:46:43 von Jim
Now I'm understanding what your refering to, but I'm looking for the event.
Where do I find the "FormView1_InsertButtonClick" code that is already
there?
"Eliyahu Goldin" wrote in
message news:%23vaOnmCWIHA.4768@TK2MSFTNGP02.phx.gbl...
> You already have a server script for FormView1_InsertButtonClick. Add
> there an event handler for SqlDataSource1_Insering. Look up a bit msdn
> topics on SqlDataSource event. There is nothing special in handling them,
> it is just a regular programming task. You will face hundreds of them as
> you proceed with asp.net development.
>
> --
> Eliyahu Goldin,
> Software Developer
> Microsoft MVP [ASP.NET]
> http://msmvps.com/blogs/egoldin
> http://usableasp.net
>
>
> "Jim" wrote in message
> news:OWE5295VIHA.4868@TK2MSFTNGP03.phx.gbl...
>>I understood number 1, but not 2 and 3. I'm thinkng 2 and 3 have to do
>>with the script and that I have no idea past what I wrote. Here is what I
>>put in for all the code. Can you help with it from what you wrote.
>> Thanks.
>> .
>> -- Start of Code ---
>> <%@ Page Language="VB" %>
>>
>>
>> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>>
>>
>>
>>
>>
>> Untitled Page
>>
>>
>>
>>
>>
>>
>> --- End of Code ---
>>
>> "Eliyahu Goldin" wrote in
>> message news:ugRm8p5VIHA.4880@TK2MSFTNGP03.phx.gbl...
>>> 1.Add to the
>>> in the datasource and add UserId to the insert sql..
>>>
>>> 2. Handle Inserting event for the datasource. In the event call
>>> User.Identity.Name to get user name and then Membership.GetUser
>>> (userName).ProviderUserKey to get user id.
>>>
>>> 3. In the same Inserting event, Locate the @UserId parameter in the
>>> insert parameter collection as e.Command.Parameters["@UserId"]. Set it's
>>> value to the user id obtained on step 2.
>>>
>>> --
>>> Eliyahu Goldin,
>>> Software Developer
>>> Microsoft MVP [ASP.NET]
>>> http://msmvps.com/blogs/egoldin
>>> http://usableasp.net
>>>
>>
>>
>
>