hi,
I have successfully made user wizard with MS access db.
Now im stuck.
I would like that user can go to the page where they could change email or signature, but i dont know how to do it. I made detail list, but it always points me to ID 1, even though its ID is 2.
The tables from MS access db aspnet_Membership,aspnet_Users, etc...are not visible when i try to configure data source for detail list, so i build a query but didnt work
Is there a video or some info somwhere where i can see how to do it as i search almost everywhere with no luck.
thank you
![]() |
1 |
![]() |
anyone? :(
![]() |
1 |
![]() |
would like that user can go to the page where they could change email or signature, but i dont know how to do it. I made detail list, but it always points me to ID 1, even though its ID is 2.
Can you provide more details on what you did?
The tables from MS access db aspnet_Membership,aspnet_Users, etc...are not visible when i try to configure data source for detail list, so i build a query but didnt work
So you are using Access Memberhip Provider correct?
/GuruBhai
![]() |
1 |
![]() |
Hi guru_sarkar
guru_sarkar:
Can you provide more details on what you did?
I created detailView from aspnet_Membership and aspnet_User table. However when i got to myprofile.aspx page it always show first record from the database. It's not showing the correct user datas.
I would that users once they register, got to myprofile.aspx page, where can change its details (like here on forum) where i can change email address or signature.
guru_sarkar:
So you are using Access Memberhip Provider correct?
yes im using Access Memberhip Provider.
QueryBuilder:SELECT aspnet_Membership.UserId, aspnet_Users.UserName, aspnet_Roles.RoleName, aspnet_Membership.Email,
aspnet_Membership.PasswordQuestion, aspnet_Membership.PasswordAnswer, aspnet_Membership.IsApproved,
aspnet_Membership.CreateDate, aspnet_Membership.LastLoginDate, aspnet_Membership.Comment, aspnet_Membership.Avatar
FROM aspnet_Roles, (aspnet_Membership INNER JOIN aspnet_Users ON aspnet_Membership.UserId = aspnet_Users.UserId)
![]() |
1 |
![]() |
looks you are not passing the logged-in userID to the query to filter the data...
Sample code to get logged-in UserID:
// Get a reference to the currently logged on user
MembershipUser currentUser = Membership.GetUser();
// Determine the currently logged on user's UserId value
Guid currentUserId = (Guid)currentUser.ProviderUserKey;
Also check this to get some more idea: http://www.asp.net/learn/security/tutorial-08-cs.aspx
/GuruBhai
![]() |
1 |
![]() |
So i should write that in code behind? im using C#....
I did found this tutorial before but i just couldnt make it to work with my data...
sorry to asking u so many question but i just started to work in asp.net so everything is still pretty much new to me and i dont understand the code yet :)
![]() |
1 |
![]() |
yes that should go in the code-behind...
The tutorial uses DetailsView and SqlDataSource ... has select Parameter as UserId whose value is set in the code-behind.
Check step -2.
What problem you faced with the tutorial code?
/GuruBhai
![]() |
1 |
![]() |
I just can't make it to work...if i do: WHERE aspnet_Membership.UserId= ?) then i get empty result...
I noticed that in step two the new table is created UserProfile...i did that and still got empty results...not sure what im missing..
im not good yet with writing code behind so is there a way to display dat afrom aspnet_User and aspnetMembership.
![]() |
1 |
![]() |
can you post your markup of page where you are trying to display the user info and anything in code-behind?
/GuruBhai
![]() |
1 |
![]() |
This is my aspx page...there's no code behind yet as i didnt know what exactly to write yet...im still reading the tutorial but just cant make it to work.
<div id="Container">
<div class="Naboj-Header"><h2>Reloading Desk
</h2></div>
<div class="Tabs-Container">
<br />
<asp:LoginView ID="LoginView1" runat="server">
<LoggedInTemplate>
<cc1:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="1"
Font-Bold="False" Width="930px">
<cc1:TabPanel ID="TabPanel1" runat="server" HeaderText="Reloading Desk">
<HeaderTemplate>
Reloading Desk
</HeaderTemplate>
<ContentTemplate>
<br />
Živjo
<asp:LoginName ID="LoginName1" runat="server" />
...kako si kaj danes?
<br />
<br />
</ContentTemplate>
</cc1:TabPanel>
<cc1:TabPanel ID="TabPanel2" runat="server" HeaderText="Moje nastavitve">
<HeaderTemplate>
Moje nastavitve
</HeaderTemplate>
<ContentTemplate>
<br />
<asp:LoginName ID="LoginName2" runat="server" />
<br />
<br />
<br />
<br />
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False"
DataSourceID="AccessDataSource1" Height="50px"
Width="125px">
<Fields>
<asp:BoundField DataField="UserId" HeaderText="UserId"
SortExpression="UserId" />
<asp:BoundField DataField="UserName" HeaderText="UserName"
SortExpression="UserName" />
<asp:BoundField DataField="RoleName" HeaderText="RoleName"
SortExpression="RoleName" />
<asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
<asp:BoundField DataField="PasswordQuestion" HeaderText="PasswordQuestion"
SortExpression="PasswordQuestion" />
<asp:BoundField DataField="PasswordAnswer" HeaderText="PasswordAnswer"
SortExpression="PasswordAnswer" />
<asp:CheckBoxField DataField="IsApproved" HeaderText="IsApproved"
SortExpression="IsApproved" />
<asp:BoundField DataField="CreateDate" HeaderText="CreateDate"
SortExpression="CreateDate" />
<asp:BoundField DataField="LastLoginDate" HeaderText="LastLoginDate"
SortExpression="LastLoginDate" />
<asp:BoundField DataField="Comment" HeaderText="Comment"
SortExpression="Comment" />
<asp:BoundField DataField="Avatar" HeaderText="Avatar"
SortExpression="Avatar" />
<asp:CommandField ShowEditButton="True" />
</Fields>
</asp:DetailsView>
<asp:AccessDataSource ID="AccessDataSource1" runat="server"
DataFile="~/App_Data/Orozje-Reloading-Center.mdb"
SelectCommand="SELECT aspnet_Membership.UserId, aspnet_Users.UserName, aspnet_Roles.RoleName, aspnet_Membership.Email, aspnet_Membership.PasswordQuestion, aspnet_Membership.PasswordAnswer, aspnet_Membership.IsApproved, aspnet_Membership.CreateDate, aspnet_Membership.LastLoginDate, aspnet_Membership.Comment, aspnet_Membership.Avatar FROM (aspnet_Membership INNER JOIN aspnet_Users ON aspnet_Membership.UserId = aspnet_Users.UserId), aspnet_Roles"
UpdateCommand="SELECT aspnet_Membership.UserId, aspnet_Users.UserName, aspnet_Roles.RoleName, aspnet_Membership.Email, aspnet_Membership.PasswordQuestion, aspnet_Membership.PasswordAnswer, aspnet_Membership.IsApproved, aspnet_Membership.CreateDate, aspnet_Membership.LastLoginDate, aspnet_Membership.Comment, aspnet_Membership.Avatar FROM (aspnet_Membership INNER JOIN aspnet_Users ON aspnet_Membership.UserId = aspnet_Users.UserId), aspnet_Roles">
</asp:AccessDataSource>
</ContentTemplate>
</cc1:TabPanel>
<cc1:TabPanel ID="TabPanel3" runat="server" HeaderText="Spremeni geslo">
<HeaderTemplate>
Spremeni geslo
</HeaderTemplate>
<ContentTemplate>
<br />
<asp:ChangePassword ID="ChangePassword2" runat="server">
<SuccessTemplate>
<table border="0" cellpadding="1" cellspacing="0"
style="border-collapse:collapse;">
<tr>
<td>
<table border="0" cellpadding="0">
<tr>
<td align="center" colspan="2">
Change Password Complete</td>
</tr>
<tr>
<td>
Your password has been changed!</td>
</tr>
<tr>
<td align="right" colspan="2">
</td>
</tr>
</table>
</td>
</tr>
</table>
</SuccessTemplate>
</asp:ChangePassword>
</ContentTemplate>
</cc1:TabPanel>
<cc1:TabPanel ID="TabPanel4" runat="server" HeaderText="Moje polnitve">
<ContentTemplate>
hjkgjhghjgjhghj
</ContentTemplate>
</cc1:TabPanel>
<cc1:TabPanel ID="TabPanel5" runat="server" HeaderText="Priljubljene polnitve">
<contentTemplate>
sdfsdfs fdsfsdf
</contentTemplate>
</cc1:TabPanel>
<cc1:TabPanel ID="TabPanel6" runat="server" HeaderText="Moji videi">
<contentTemplate>
rderetrertet
</contentTemplate>
</cc1:TabPanel>
<cc1:TabPanel ID="TabPanel7" runat="server" HeaderText="Priljubljeni videi">
<contentTemplate>
dsfsfds gfrdgfdfgdfg gfd
</contentTemplate>
</cc1:TabPanel>
</cc1:TabContainer>
</LoggedInTemplate>
<AnonymousTemplate>
<br />
<asp:Login ID="Login1" runat="server" PasswordRecoveryText="Pozabili geslo?">
</asp:Login>
</AnonymousTemplate>
</asp:LoginView>
</div>
</div>
thanks again for helping me with that..really appreciated.
![]() |
1 |
![]() |
How about trying this right now and see if you get some success:
In your code behind add this:
protected void AccessDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e){
MembershipUser currentUser = Membership.GetUser(); Guid currentUserId = (Guid)currentUser.ProviderUserKey;e.Command.Parameters["@UserId"].Value = currentUserId;}
Modify your DetailsView like this:
<asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="125px" DataSourceID="AccessDataSource1" AutoGenerateRows="False" DataKeyNames="UserId"> <Fields><asp:BoundField DataField="UserId" HeaderText="UserId" ReadOnly="True" SortExpression="UserId" /><asp:BoundField DataField="UserName" HeaderText="UserName" SortExpression="UserName" /> <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" /><asp:BoundField DataField="PasswordQuestion" HeaderText="PasswordQuestion" SortExpression="PasswordQuestion" /><asp:BoundField DataField="PasswordAnswer" HeaderText="PasswordAnswer" SortExpression="PasswordAnswer" /><asp:CheckBoxField DataField="IsApproved" HeaderText="IsApproved" SortExpression="IsApproved" /><asp:BoundField DataField="CreateDate" HeaderText="CreateDate" SortExpression="CreateDate" /><asp:BoundField DataField="LastLoginDate" HeaderText="LastLoginDate" SortExpression="LastLoginDate" /><asp:BoundField DataField="Comment" HeaderText="Comment" SortExpression="Comment" /> </Fields> </asp:DetailsView>And your AccessDataSource Something like this:
<asp:AccessDataSource ID="AccessDataSource1" runat="server" onselecting="AccessDataSource1_Selecting" DataFile="~/App_Data/Orozje-Reloading-Center.mdb"SelectCommand
="SELECT aspnet_Membership.UserId, aspnet_Users.UserName, aspnet_Membership.Email, aspnet_Membership.PasswordQuestion, aspnet_Membership.PasswordAnswer, aspnet_Membership.IsApproved, aspnet_Membership.CreateDate, aspnet_Membership.LastLoginDate, aspnet_Membership.Comment FROM aspnet_Membership INNER JOIN aspnet_Users ON aspnet_Membership.UserId = aspnet_Users.UserId WHERE (aspnet_Membership.UserId = @UserId)"><
SelectParameters><asp:ControlParameter ControlID="DetailsView1" Name="UserId" PropertyName="SelectedValue" /> </SelectParameters></asp:AccessDataSource>
/GuruBhai
![]() |
1 |
![]() |
hi,
thank you for the code...I placed it and i got thios error, line 16
Specified cast is not valid.
Line 14: MembershipUser currentUser = Membership.GetUser();
Line 15:
Line 16: Guid currentUserId = (Guid)currentUser.ProviderUserKey;
Line 17: e.Command.Parameters["@UserId"].Value = currentUserId;
Line 18:
![]() |
1 |
![]() |