-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUpdateAuthor.aspx.cs
59 lines (53 loc) · 1.68 KB
/
UpdateAuthor.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
49
50
51
52
53
54
55
56
57
58
59
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class UpdateArtistForm : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Page.MaintainScrollPositionOnPostBack = true;
databind();
}
private void databind()
{
gvArtist.DataSource = (List<Author>)Application["authors"];
gvArtist.DataBind();
}
protected void gvArtist_SelectedIndexChanged(object sender, EventArgs e)
{
List<Author> authors = (List<Author>)Application["authors"];
Author a = authors[gvArtist.SelectedIndex+gvArtist.PageIndex*gvArtist.PageSize];
tbxId.Text = a.Id;
tbxName.Text = a.Name;
tbxProfile.Text = a.Profile;
tbxDateOfBirth.Text = String.Format("{0:yyyy-MM-dd}", a.Dob);
Session["authors"] = a;
}
protected void btnAdd_Click(object sender, EventArgs e)
{
Author a = (Author)Session["authors"];
a.Name = tbxName.Text;
a.Profile = tbxProfile.Text;
a.Dob = Convert.ToDateTime(tbxDateOfBirth.Text);
lblOutput.Text = "updated!";
databind();
}
protected void gvArtist_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gvArtist.PageIndex = e.NewPageIndex;
databind();
}
protected void btnSearch_Click(object sender, EventArgs e)
{
//not done
}
protected void gvArtist_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
List<Author> authors = (List<Author>)Application["authors"];
authors.RemoveAt(e.RowIndex);
databind();
}
}