-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTestData.cs
51 lines (43 loc) · 1.31 KB
/
TestData.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
using System.ComponentModel;
using System.Web;
using System.Web.SessionState;
public class DataRow {
private int fId;
private string fDescription;
public DataRow(int id, string description){
fId = id;
fDescription = description;
}
public int ID {
get { return fId; }
set { fId = value; }
}
public string Description {
get { return fDescription;}
set { fDescription = value; }
}
}
public class GridDataSource {
HttpSessionState Session { get { return HttpContext.Current.Session; } }
public BindingList<DataRow> GetRows() {
if (Session["GridDataSource"] == null) CreateRows();
return Session["GridDataSource"] as BindingList<DataRow>;
}
public void CreateRows() {
BindingList<DataRow> res = new BindingList<DataRow>();
for (int i = 1; i <= 25; i++){
DataRow item = new DataRow(i, "Sample data for row " + i);
res.Add(item);
}
Session["GridDataSource"] = res;
}
public void DeleteRow(int id) {
BindingList<DataRow> rows = Session["GridDataSource"] as BindingList<DataRow>;
for (int i = 0; i < rows.Count; i++) {
if (rows[i].ID == id){
rows.Remove(rows[i]);
break;
}
}
}
}