Welcome to mirror list, hosted at ThFree Co, Russian Federation.

DataGridColumn_FooterStyle.aspx.cs « DataGridColumn « System_Web_UI_WebControls « MainsoftWebApp « mainsoft « Test « System.Web « class « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b5447c40dec62e729e98ec7cf4a83b08c9d4f934 (plain)
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
//
// Authors:
//   Rafael Mizrahi   <rafim@mainsoft.com>
//   Erez Lotan       <erezl@mainsoft.com>
//   Vladimir Krasnov <vladimirk@mainsoft.com>
//
//
// Copyright (c) 2002-2005 Mainsoft Corporation.
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

using System;
using System.Data;
using System.Collections;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace GHTTests.System_Web_dll.System_Web_UI_WebControls
{
	public class DataGridColumn_FooterStyle
		: GHTBaseWeb 
	{
		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e) 
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent() 
		{    
			this.Load += new System.EventHandler(this.Page_Load);
		}
		#endregion

		#region "Template Classes"
		public class t_DBLitTemplate : ITemplate
		{
			public void InstantiateIn(Control container)
			{
				Literal literal1 = new Literal();
				literal1.Text = "<div>";
				literal1.DataBinding += new EventHandler(this.BindData);
				container.Controls.Add(literal1);
			}
			public void BindData(object sender, EventArgs e)
			{
				Literal literal1 = (Literal) sender;
				DataGridItem item1 = (DataGridItem) literal1.NamingContainer;
				literal1.Text = DataBinder.Eval(item1.DataItem, "Name") + "</div>";
			}
		}
		public class t_EmptyLitTemplate : ITemplate
		{
			public void InstantiateIn(Control container)
			{
				Literal literal1 = new Literal();
				literal1.Text = "";
				container.Controls.Add(literal1);
			}
		}
		public class t_PlainTextLitTemplate : ITemplate
		{
			public void InstantiateIn(Control container)
			{
				Literal literal1 = new Literal();
				literal1.Text = "Plain text template create at run time";
				container.Controls.Add(literal1);
			}
		}
		public class t_HtmlLitTemplate : ITemplate
		{
			public void InstantiateIn(Control container)
			{
				Literal literal1 = new Literal();
				literal1.Text = "<div><b><i>Html template created at run time</i></b></div>";
				container.Controls.Add(literal1);
			}
		}
		public class t_ControlLitTemplate : ITemplate
		{
			public void InstantiateIn(Control container)
			{
				HtmlInputButton button1 = new HtmlInputButton();
				button1.Value = "Control template";
				container.Controls.Add(button1);
			}
		}
		#endregion

		#region "DataGrid creation functions"
		private void setText(DataGridColumn c, ListItemType tp, string text)
		{
			switch (tp)
			{
				case ListItemType.Header:
				{
					c.HeaderText = text;
					return;
				}
				case ListItemType.Footer:
				{
					c.FooterText = text;
					return;
				}
			}
		}
 
		private void setStyle(DataGridColumn c, ListItemType tp)
		{
			switch (tp)
			{
				case ListItemType.Header:
				{
					c.HeaderStyle.VerticalAlign = VerticalAlign.Top;
					c.HeaderStyle.HorizontalAlign = HorizontalAlign.Right;
					c.HeaderStyle.Wrap = false;
					return;
				}
				case ListItemType.Footer:
				{
					c.FooterStyle.VerticalAlign = VerticalAlign.Top;
					c.FooterStyle.HorizontalAlign = HorizontalAlign.Right;
					c.FooterStyle.Wrap = false;
					return;
				}
				case ListItemType.Item:
				{
					c.ItemStyle.VerticalAlign = VerticalAlign.Top;
					c.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
					c.ItemStyle.Wrap = false;
					return;
				}
			}
		}
 
		private DataGridColumn c_bounded(ListItemType tp, string text)
		{
			BoundColumn column1 = new BoundColumn();
			column1.DataField = "ID";
			this.setStyle(column1, tp);
			this.setText(column1, tp, text);
			return column1;
		}
 
		private DataGridColumn c_button(ListItemType tp, string text)
		{
			ButtonColumn column1 = new ButtonColumn();
			column1.DataTextField = "ID";
			this.setStyle(column1, tp);
			this.setText(column1, tp, text);
			return column1;
		}
 
		private DataGridColumn c_hyper_link(ListItemType tp, string text)
		{
			HyperLinkColumn column1 = new HyperLinkColumn();
			column1.DataTextField = "ID";
			column1.NavigateUrl = "http://www.google.com";
			this.setStyle(column1, tp);
			this.setText(column1, tp, text);
			return column1;
		}
 
		private DataGridColumn c_edit(ListItemType tp, string text)
		{
			EditCommandColumn column1 = new EditCommandColumn();
			column1.EditText = "Edit";
			this.setStyle(column1, tp);
			this.setText(column1, tp, text);
			return column1;
		}
 
		private DataGridColumn c_template(ListItemType tp, string text)
		{
			TemplateColumn column1 = new TemplateColumn();
			column1.ItemTemplate = new DataGridColumn_FooterStyle.t_DBLitTemplate();
			this.setStyle(column1, tp);
			this.setText(column1, tp, text);
			return column1;
		}
 
		private void DataGridTest(string TestName, DataGridColumn c)

		{
			DataGrid dg = new DataGrid();

			GHTSubTestBegin(TestName);
			try 
			{
				dg.Columns.Add(c);
				dg.DataSource = GHTTests.GHDataSources.DSDataTable();
				dg.ShowFooter = true;
				dg.DataBind();
				GHTActiveSubTest.Controls.Add(dg);
			}
			catch (Exception ex) 
			{
				GHTSubTestUnexpectedExceptionCaught(ex);
				dg = null;
			}
			GHTSubTestEnd();

		}
		#endregion

		private void Page_Load(object sender, System.EventArgs e) 
		{
			//Put user code to initialize the page here

			System.Web.UI.HtmlControls.HtmlForm frm = (HtmlForm)this.FindControl("Form1");
			GHTTestBegin(frm);

			DataGridTest("GhtSubTest1", c_bounded(ListItemType.Footer, "Footer"));
			DataGridTest("GhtSubTest2", c_button(ListItemType.Footer, "Footer"));
			DataGridTest("GhtSubTest3", c_edit(ListItemType.Footer, "Footer"));
			DataGridTest("GhtSubTest4", c_hyper_link(ListItemType.Footer, "Footer"));
			DataGridTest("GhtSubTest5", c_template(ListItemType.Footer, "Footer"));

			GHTTestEnd();
		}
	}
}