|
1
|
|
#region Copyright
|
|
2
|
|
|
|
3
|
|
|
|
4
|
|
|
|
5
|
|
|
|
6
|
|
|
|
7
|
|
|
|
8
|
|
|
|
9
|
|
|
|
10
|
|
|
|
11
|
|
|
|
12
|
|
|
|
13
|
|
|
|
14
|
|
|
|
15
|
|
|
|
16
|
|
|
|
17
|
|
|
|
18
|
|
|
|
19
|
|
|
|
20
|
|
|
|
21
|
|
|
|
22
|
|
#endregion
|
|
23
|
|
|
|
24
|
|
using System;
|
|
25
|
|
using System.Reflection;
|
|
26
|
|
using System.Web.UI;
|
|
27
|
|
using System.Web.UI.WebControls;
|
|
28
|
|
using ShowX.Config;
|
|
29
|
|
using ShowX.Model;
|
|
30
|
|
using DataGrid = ShowX.Web.WebControls.DataGrid;
|
|
31
|
|
|
|
32
|
|
namespace ShowX.Web.WebBuilders.ItemTemplates
|
|
33
|
|
{
|
|
34
|
|
|
|
35
|
|
|
|
36
|
|
|
|
37
|
|
|
|
38
|
|
class ItemTemplate : ITemplate {
|
|
39
|
|
|
|
40
|
|
|
|
41
|
|
|
|
42
|
|
|
|
43
|
|
protected PropertyInfo propertyInfo;
|
|
44
|
|
|
|
45
|
|
|
|
46
|
|
|
|
47
|
|
|
|
48
|
|
|
|
49
|
280
|
public ItemTemplate(PropertyInfo propertyInfo)
|
|
50
|
|
{
|
|
51
|
280
|
this.propertyInfo = propertyInfo;
|
|
52
|
|
}
|
|
53
|
|
|
|
54
|
|
|
|
55
|
|
|
|
56
|
|
|
|
57
|
|
|
|
58
|
|
|
|
59
|
890
|
public void InstantiateIn(Control container)
|
|
60
|
|
{
|
|
61
|
890
|
IPropertyMap dbattr =
|
|
62
|
|
Configuration.Session.MappingHandler.GetPropertyMap(propertyInfo);
|
|
63
|
|
|
|
64
|
890
|
if (propertyInfo.PropertyType == typeof(Boolean)) {
|
|
65
|
|
|
|
66
|
126
|
CheckBox cb = new CheckBox();
|
|
67
|
126
|
cb.DataBinding += new EventHandler(cb_DataBinding);
|
|
68
|
|
|
|
69
|
126
|
container.Controls.Add(cb);
|
|
70
|
|
}
|
|
71
|
764
|
else if (propertyInfo.PropertyType == typeof(DateTime)) {
|
|
72
|
|
|
|
73
|
126
|
Literal ldate = new Literal();
|
|
74
|
126
|
ldate.DataBinding += new EventHandler(ldate_DataBinding);
|
|
75
|
|
|
|
76
|
126
|
container.Controls.Add(ldate);
|
|
77
|
|
}
|
|
78
|
|
else {
|
|
79
|
|
|
|
80
|
638
|
if (dbattr.ItemStyle == ItemStyle.HyperLink) {
|
|
81
|
|
|
|
82
|
0
|
LinkButton hl = new LinkButton();
|
|
83
|
|
|
|
84
|
0
|
hl.DataBinding += new EventHandler(LinkButton_DataBinding);
|
|
85
|
0
|
hl.CommandName = "ItemCommand";
|
|
86
|
|
|
|
87
|
0
|
container.Controls.Add(hl);
|
|
88
|
|
}
|
|
89
|
|
else {
|
|
90
|
|
|
|
91
|
638
|
Literal lc = new Literal();
|
|
92
|
|
|
|
93
|
638
|
if (dbattr.IsPassword)
|
|
94
|
126
|
lc.Text = "(Not show)";
|
|
95
|
|
else
|
|
96
|
512
|
lc.DataBinding += new EventHandler(TemplateControl_DataBinding);
|
|
97
|
|
|
|
98
|
638
|
container.Controls.Add(lc);
|
|
99
|
|
}
|
|
100
|
|
}
|
|
101
|
|
}
|
|
102
|
|
|
|
103
|
|
|
|
104
|
|
|
|
105
|
|
|
|
106
|
|
|
|
107
|
|
|
|
108
|
|
|
|
109
|
512
|
private void TemplateControl_DataBinding(object sender, EventArgs e)
|
|
110
|
|
{
|
|
111
|
512
|
Literal lc;
|
|
112
|
512
|
lc = (Literal) sender;
|
|
113
|
512
|
DataGridItem container = (DataGridItem) lc.NamingContainer;
|
|
114
|
|
|
|
115
|
512
|
lc.Text += DataBinder.Eval(container.DataItem,propertyInfo.Name);
|
|
116
|
|
}
|
|
117
|
|
|
|
118
|
|
|
|
119
|
|
|
|
120
|
|
|
|
121
|
|
|
|
122
|
|
|
|
123
|
|
|
|
124
|
126
|
private void cb_DataBinding(object sender, EventArgs e)
|
|
125
|
|
{
|
|
126
|
126
|
CheckBox cb;
|
|
127
|
126
|
cb = (CheckBox) sender;
|
|
128
|
126
|
DataGridItem container = (DataGridItem) cb.NamingContainer;
|
|
129
|
126
|
cb.Checked = Convert.ToBoolean(
|
|
130
|
|
DataBinder.Eval(container.DataItem,propertyInfo.Name));
|
|
131
|
126
|
cb.Enabled = false;
|
|
132
|
|
}
|
|
133
|
|
|
|
134
|
126
|
private void ldate_DataBinding(object sender, EventArgs e)
|
|
135
|
|
{
|
|
136
|
126
|
Literal ldate;
|
|
137
|
126
|
ldate = (Literal) sender;
|
|
138
|
126
|
DataGridItem container = (DataGridItem) ldate.NamingContainer;
|
|
139
|
126
|
DateTime date = (DateTime)DataBinder.Eval(container.DataItem,
|
|
140
|
|
propertyInfo.Name);
|
|
141
|
|
|
|
142
|
126
|
DataGrid dg = container.Parent.Parent as DataGrid;
|
|
143
|
|
|
|
144
|
126
|
if (dg.DateTimeFormat == "")
|
|
145
|
35
|
ldate.Text = date.ToString();
|
|
146
|
|
else
|
|
147
|
91
|
ldate.Text = date.ToString(dg.DateTimeFormat);
|
|
148
|
|
}
|
|
149
|
|
|
|
150
|
0
|
private void LinkButton_DataBinding(object sender, EventArgs e) {
|
|
151
|
|
|
|
152
|
|
IPropertyMap dbattr =
|
|
153
|
|
Configuration.Session.MappingHandler.GetPropertyMap(propertyInfo);
|
|
154
|
|
|
|
155
|
|
LinkButton hl;
|
|
156
|
|
hl = (LinkButton) sender;
|
|
157
|
|
DataGridItem container = (DataGridItem) hl.NamingContainer;
|
|
158
|
|
|
|
159
|
|
hl.Text += DataBinder.Eval(container.DataItem,propertyInfo.Name);
|
|
160
|
|
|
|
161
|
|
}
|
|
162
|
|
}
|
|
163
|
|
}
|
|
164
|
|
|