User and Role Management for an ASP.NET AJAX Server-Centric Based Online Shopping Website - User Management
(Page 4 of 6 )
User Management
The first point to notice is that the "Usermange.aspx" page can be run independently. It can also be run in the mode that grants the current user the identity of the "Super Administrator" role when he logs into the system. The second point to notice is that this is still a pure ASP.NET page. To simplify the design we isolate the "Adding a New User" operation from the main page (i.e. herein the "Usermange.aspx" page). Maybe in other design ideas the adding operation together with the "Usermange.aspx" page will be incorporated into one page, which will drastically increase the complexity of the design. The design complexity will also be increased, of course, when other ASP.NET AJAX solutions are advised to be used such as the UpdatePanelcontrol as well as the PopupControl Extender to facilitate the in-place editing, etc.
As usual, let’s first have a look at the design-time snapshot of the "Usermange.aspx" page, as shown in Figure 13.
Figure 13—the design-time snapshot for managing users
/Building_ASP.NET_AJAX_Server-Centric_Shopping_Website(4)_html_5bbd0e4f.png)
Seen from the above figure, the following functionalities will be performed in this page:
Display the present users’ info in an ASP.NET 2.0 GridView control.
Provide hyperlinks to add new users by clicking the "Add new user" button.
Provide hyperlinks to modify ready users by clicking the "Edit" hyperlink within the GridView control.
Delete current users by clicking the "X" hyperlink within the GridView control.
View the interested user’s detailed info by clicking the fields in the "User Name" column within the GridView control to redirect the current user to another "UserInfo.aspx" page.
Page Initialization
During the course of the initialization of the page, the main functionality is to display the general user info within the GridView control, i.e. binding data to the "UserView" GridView. The associated code is listed as follows:
protected void Page_Load(object sender,EventArgs e)
{ ///bind data to the GridView control
if(!Page.IsPostBack) {
BindUserData();
}
}
private void BindUserData(){
///define the class that gets the data
User user = new User();
SqlDataReader dr = user.GetUsers();
///Set the control's data source
UserView.DataSource = dr;
///bind data to the control
UserView.DataBind();
///Close the database connection
dr.Close();
}
Here with the help of the GetUsers member methodof the User class, we have easily achieved our goal.
Next: Deleting the Selected User >>
More ASP.NET Articles
More By Xianzhong Zhu