Hi Doug,
Can you get it from the Profile? If so, here's some code that might get you
going.
Let us know?
Ken
Microsoft MVP [ASP.NET]
<%@ Page Language="VB" %>
<%@ import namespace="System.Data" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub Page_Load _
(ByVal sender As Object, _
ByVal e As System.EventArgs)
If Not IsNothing(Profile.UserName) Then
SqlDataSource1.SelectParameters.Item _
("UserName"). _
DefaultValue = Profile.UserName
Else
SqlDataSource1.SelectCommand = ""
End If
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Get the UserID from ASPNET users database [Ken Cox]</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<p>
<asp:listbox id="ListBox1" runat="server" datasourceid="SqlDataSource1"
datatextfield="Uid"></asp:listbox></p>
<asp:sqldatasource
id="SqlDataSource1"
runat="server"
connectionstring="<%$ ConnectionStrings:ASPNETDBConnectionString %>"
selectcommand="SELECT UserId AS Uid FROM vw_aspnet_Users WHERE (UserName =
@UserName)">
<selectparameters>
<asp

arameter name="UserName" />
</selectparameters>
</asp:sqldatasource>
</div>
</form>
</body>
</html>
"Doug Batchelor" <> wrote in message
news:...
>I am using the ASP.NET membership stuff and have succesfully implemented it
>on my site. However, I would now like to be able to get the UserId which is
>stored for registered users in the aspnet_users table in ASPNETDB.MDF. The
>reason is that I would like to include this value for users who insert
>records in other tables in my database. I thought I could use the LoginName
>control to get the Username which I could then use to query the
>aspnet_users table, but I can't find a property which will give me the
>Username in the control.
>
> I would appreciate any help from the gurus out there.
>