Click here to Skip to main content
15,879,095 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
hi every one:
i want that when user login then dispaly his/her
name on the welcome page and show all of the data in
gridview like username,firstname,lastname.
Posted
Comments
uspatel 22-Feb-13 4:50am    
did you try anything?

1 solution

i do no t know why do you need that. Here is a solution of your problem. but i do not think it will be a good idea to show the user profile to a gridveiw. Cause gridview is not memory effective to display a few items.

Here is the solution. First of all gridview works with list of data. As you have one one data i guess but you also need to make a list in order to display it with gridview.

This is the method to find out the logged in user as a list:
XML
public List<User> GetUserByUserNamePassword(string UserName,string Password)
{
  var availableUser= (from user in _DatabaseContext.Users
                    where user.FirstName == UserName && user.Password == Password
                    select user
                     ).ToList();
            return availableUser;
}


And here is the code for binding the gridview.

XML
List<User> user = new UserBLL().GetUserByUserNamePassword("palash", "123");
if (user != null)
{
    grvUser.DataSource = user;
    grvUser.DataBind();
}

Hope it will help.
Happy coding....
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900