* roottypes.cs: Rename from tree.cs.
[mono.git] / mcs / class / System.Web / Test / mainsoft / MainsoftWebApp / System_Web_UI_WebControls / DataGridColumn / DataGridColumn_FooterText.aspx.cs
1 //
2 // Authors:
3 //   Rafael Mizrahi   <rafim@mainsoft.com>
4 //   Erez Lotan       <erezl@mainsoft.com>
5 //   Vladimir Krasnov <vladimirk@mainsoft.com>
6 //
7 //
8 // Copyright (c) 2002-2005 Mainsoft Corporation.
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
17 //
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
20 //
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 //
29
30 using System;
31 using System.Data;
32 using System.Collections;
33 using System.Web;
34 using System.Web.UI;
35 using System.Web.UI.WebControls;
36 using System.Web.UI.HtmlControls;
37
38 namespace GHTTests.System_Web_dll.System_Web_UI_WebControls
39 {
40         public class DataGridColumn_FooterText
41                 : GHTBaseWeb 
42         {
43                 #region Web Form Designer generated code
44                 override protected void OnInit(EventArgs e) 
45                 {
46                         //
47                         // CODEGEN: This call is required by the ASP.NET Web Form Designer.
48                         //
49                         InitializeComponent();
50                         base.OnInit(e);
51                 }
52                 
53                 /// <summary>
54                 /// Required method for Designer support - do not modify
55                 /// the contents of this method with the code editor.
56                 /// </summary>
57                 private void InitializeComponent() 
58                 {    
59                         this.Load += new System.EventHandler(this.Page_Load);
60                 }
61                 #endregion
62
63                 #region "Template Classes"
64                 public class t_DBLitTemplate : ITemplate
65                 {
66                         public void InstantiateIn(Control container)
67                         {
68                                 Literal literal1 = new Literal();
69                                 literal1.Text = "<div>";
70                                 literal1.DataBinding += new EventHandler(this.BindData);
71                                 container.Controls.Add(literal1);
72                         }
73                         public void BindData(object sender, EventArgs e)
74                         {
75                                 Literal literal1 = (Literal) sender;
76                                 DataGridItem item1 = (DataGridItem) literal1.NamingContainer;
77                                 literal1.Text = DataBinder.Eval(item1.DataItem, "Name") + "</div>";
78                         }
79                 }
80                 public class t_EmptyLitTemplate : ITemplate
81                 {
82                         public void InstantiateIn(Control container)
83                         {
84                                 Literal literal1 = new Literal();
85                                 literal1.Text = "";
86                                 container.Controls.Add(literal1);
87                         }
88                 }
89                 public class t_PlainTextLitTemplate : ITemplate
90                 {
91                         public void InstantiateIn(Control container)
92                         {
93                                 Literal literal1 = new Literal();
94                                 literal1.Text = "Plain text template create at run time";
95                                 container.Controls.Add(literal1);
96                         }
97                 }
98                 public class t_HtmlLitTemplate : ITemplate
99                 {
100                         public void InstantiateIn(Control container)
101                         {
102                                 Literal literal1 = new Literal();
103                                 literal1.Text = "<div><b><i>Html template created at run time</i></b></div>";
104                                 container.Controls.Add(literal1);
105                         }
106                 }
107                 public class t_ControlLitTemplate : ITemplate
108                 {
109                         public void InstantiateIn(Control container)
110                         {
111                                 HtmlInputButton button1 = new HtmlInputButton();
112                                 button1.Value = "Control template";
113                                 container.Controls.Add(button1);
114                         }
115                 }
116                 #endregion
117
118                 #region "DataGrid creation functions"
119                 private void setText(DataGridColumn c, ListItemType tp, string text)
120                 {
121                         switch (tp)
122                         {
123                                 case ListItemType.Header:
124                                 {
125                                         c.HeaderText = text;
126                                         return;
127                                 }
128                                 case ListItemType.Footer:
129                                 {
130                                         c.FooterText = text;
131                                         return;
132                                 }
133                         }
134                 }
135  
136                 private void setStyle(DataGridColumn c, ListItemType tp)
137                 {
138                 }
139  
140                 private DataGridColumn c_bounded(ListItemType tp, string text)
141                 {
142                         BoundColumn column1 = new BoundColumn();
143                         column1.DataField = "ID";
144                         this.setStyle(column1, tp);
145                         this.setText(column1, tp, text);
146                         return column1;
147                 }
148  
149                 private DataGridColumn c_button(ListItemType tp, string text)
150                 {
151                         ButtonColumn column1 = new ButtonColumn();
152                         column1.DataTextField = "ID";
153                         this.setStyle(column1, tp);
154                         this.setText(column1, tp, text);
155                         return column1;
156                 }
157  
158                 private DataGridColumn c_hyper_link(ListItemType tp, string text)
159                 {
160                         HyperLinkColumn column1 = new HyperLinkColumn();
161                         column1.DataTextField = "ID";
162                         column1.NavigateUrl = "http://www.google.com";
163                         this.setStyle(column1, tp);
164                         this.setText(column1, tp, text);
165                         return column1;
166                 }
167  
168                 private DataGridColumn c_edit(ListItemType tp, string text)
169                 {
170                         EditCommandColumn column1 = new EditCommandColumn();
171                         column1.EditText = "Edit";
172                         this.setStyle(column1, tp);
173                         this.setText(column1, tp, text);
174                         return column1;
175                 }
176  
177                 private DataGridColumn c_template(ListItemType tp, string text)
178                 {
179                         TemplateColumn column1 = new TemplateColumn();
180                         column1.ItemTemplate = new DataGridColumn_FooterStyle.t_DBLitTemplate();
181                         this.setStyle(column1, tp);
182                         this.setText(column1, tp, text);
183                         return column1;
184                 }
185  
186                 private void DataGridTest(string TestName, DataGridColumn c)
187
188                 {
189                         DataGrid dg = new DataGrid();
190
191                         GHTSubTestBegin(TestName);
192                         try 
193                         {
194                                 dg.Columns.Add(c);
195                                 dg.DataSource = GHTTests.GHDataSources.DSDataTable();
196                                 dg.ShowFooter = true;
197                                 dg.DataBind();
198                                 GHTActiveSubTest.Controls.Add(dg);
199                         }
200                         catch (Exception ex) 
201                         {
202                                 GHTSubTestUnexpectedExceptionCaught(ex);
203                                 dg = null;
204                         }
205                         GHTSubTestEnd();
206
207                 }
208                 #endregion
209
210                 private void Page_Load(object sender, System.EventArgs e) 
211                 {
212                         //Put user code to initialize the page here
213
214                         System.Web.UI.HtmlControls.HtmlForm frm = (HtmlForm)this.FindControl("Form1");
215                         GHTTestBegin(frm);
216
217                         DataGridTest("GhtSubTest1", c_bounded(ListItemType.Footer, ""));
218                         DataGridTest("GhtSubTest2", c_button(ListItemType.Footer, ""));
219                         DataGridTest("GhtSubTest3", c_edit(ListItemType.Footer, ""));
220                         DataGridTest("GhtSubTest4", c_hyper_link(ListItemType.Footer, ""));
221                         DataGridTest("GhtSubTest5", c_template(ListItemType.Footer, ""));
222                         DataGridTest("GhtSubTest6", c_bounded(ListItemType.Footer, "Footer text"));
223                         DataGridTest("GhtSubTest7", c_button(ListItemType.Footer, "Footer text"));
224                         DataGridTest("GhtSubTest8", c_edit(ListItemType.Footer, "Footer text"));
225                         DataGridTest("GhtSubTest9", c_hyper_link(ListItemType.Footer, "Footer text"));
226                         DataGridTest("GhtSubTest10", c_template(ListItemType.Footer, "Footer text"));
227
228                         GHTTestEnd();
229                 }
230         }
231 }