-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUsers.aspx.cs
48 lines (41 loc) · 1.42 KB
/
Users.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Web.UI;
using System.Web.UI.WebControls;
using webapplication_aspx.Models;
using webapplication_aspx.Services;
namespace webapplication_aspx
{
public partial class Users : Page
{
protected void Page_Load(object sender, EventArgs e)
{
RegisterAsyncTask(new PageAsyncTask(LoadDataAsync));
}
private async Task LoadDataAsync()
{
if (Session["AuthenticationResult"] != null)
{
UserService userService = new UserService();
List<User> users = await userService.GetAllUsers();
UsersGridView.DataSource = users;
UsersGridView.DataBind();
}
}
protected void UsersGridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Button detailsButton = (Button)e.Row.FindControl("DetailsButton");
string id = UsersGridView.DataKeys[e.Row.RowIndex].Value.ToString();
detailsButton.PostBackUrl = $"UserDetails.aspx?id={id}";
}
}
protected void ButtonCreate_Click(object sender, EventArgs e)
{
if (Session["AuthenticationResult"] != null)
Response.Redirect("UserDetails.aspx?id=0");
}
}
}