Hello.
My problem is I want to get the userid from default login which is on the database.
I need to build a website which certain user login and the data display only it assigned by the user.
For example, a teacher login and then the data only display for teacher's class.
You can use Membership.GetUser() to get the information for a membership user from the data source at first. Then check the user and select data according to the user as follows:
if(Membership.GetUser()==sepcialuser )
{
con.Open();
SqlCommand cmd = new SqlCommand("select LastName from datetable1 ",con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
con.Close();
Listview1.DataSource = ds;
Listview1.DataBind();
}
Best wishes,
Please mark the replies as answers if they help or unmark if not.
Feedback to us
khairiez
None
0 Points
19 Posts
Get current UserId from default login
Nov 13, 2012 11:34 AM|LINK
Hello.
My problem is I want to get the userid from default login which is on the database.
I need to build a website which certain user login and the data display only it assigned by the user.
For example, a teacher login and then the data only display for teacher's class.
Thank you.
mezzanine74
Contributor
2480 Points
730 Posts
Re: Get current UserId from default login
Nov 13, 2012 11:53 AM|LINK
khairiez
None
0 Points
19 Posts
Re: Get current UserId from default login
Nov 13, 2012 01:43 PM|LINK
Catherine Sh...
All-Star
23382 Points
2490 Posts
Microsoft
Re: Get current UserId from default login
Nov 20, 2012 02:45 AM|LINK
Hi khairiez,
Sorry for delay reply.
You can use Membership.GetUser() to get the information for a membership user from the data source at first. Then check the user and select data according to the user as follows:
if(Membership.GetUser()==sepcialuser ) { con.Open(); SqlCommand cmd = new SqlCommand("select LastName from datetable1 ",con); SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds); con.Close(); Listview1.DataSource = ds; Listview1.DataBind(); }Best wishes,
Feedback to us
Develop and promote your apps in Windows Store
khairiez
None
0 Points
19 Posts
Re: Get current UserId from default login
Nov 26, 2012 01:29 AM|LINK