* roottypes.cs: Rename from tree.cs.
[mono.git] / mcs / class / System.Web / Test / mainsoft / MainsoftWebApp / System_Web_UI_WebControls / DataGridColumn / DataGridColumn_SortExpression.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_SortExpression
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                         switch (tp)
139                         {
140                                 case ListItemType.Header:
141                                 {
142                                         c.HeaderStyle.VerticalAlign = VerticalAlign.Top;
143                                         c.HeaderStyle.HorizontalAlign = HorizontalAlign.Right;
144                                         c.HeaderStyle.Wrap = false;
145                                         return;
146                                 }
147                                 case ListItemType.Footer:
148                                 {
149                                         c.FooterStyle.VerticalAlign = VerticalAlign.Top;
150                                         c.FooterStyle.HorizontalAlign = HorizontalAlign.Right;
151                                         c.FooterStyle.Wrap = false;
152                                         return;
153                                 }
154                                 case ListItemType.Item:
155                                 {
156                                         c.ItemStyle.VerticalAlign = VerticalAlign.Top;
157                                         c.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
158                                         c.ItemStyle.Wrap = false;
159                                         return;
160                                 }
161                         }
162                 }
163  
164                 private DataGridColumn c_bounded(string se)
165                 {
166                         BoundColumn column1 = new BoundColumn();
167                         column1.DataField = "ID";
168                         column1.SortExpression = se;
169                         return column1;
170                 }
171  
172  
173                 private DataGridColumn c_button(string se)
174                 {
175                         ButtonColumn column1 = new ButtonColumn();
176                         column1.DataTextField = "ID";
177                         column1.SortExpression = se;
178                         return column1;
179                 }
180  
181                 private DataGridColumn c_hyper_link(string se)
182                 {
183                         HyperLinkColumn column1 = new HyperLinkColumn();
184                         column1.DataTextField = "ID";
185                         column1.NavigateUrl = "http://www.google.com";
186                         column1.SortExpression = se;
187                         return column1;
188                 }
189  
190                 private DataGridColumn c_edit(string se)
191                 {
192                         EditCommandColumn column1 = new EditCommandColumn();
193                         column1.EditText = "Edit";
194                         column1.SortExpression = se;
195                         return column1;
196                 }
197  
198                 private DataGridColumn c_template(string se)
199                 {
200                         TemplateColumn column1 = new TemplateColumn();
201                         column1.ItemTemplate = new DataGridColumn_SortExpression.t_DBLitTemplate();
202                         column1.SortExpression = se;
203                         return column1;
204                 }
205  
206                 private void DataGridTest(string TestName, DataGridColumn c)
207                 {
208                         DataGrid grid1 = new DataGrid();
209                         this.GHTSubTestBegin(TestName);
210                         try
211                         {
212                                 grid1.Columns.Add(c);
213                                 grid1.DataSource = GHTTests.GHDataSources.DSDataTable();
214                                 grid1.ShowFooter = true;
215                                 grid1.DataBind();
216                                 base.GHTActiveSubTest.Controls.Add(grid1);
217                                 this.GHTSubTestAddResult(grid1.Columns[0].SortExpression);
218                         }
219                         catch (Exception exception2)
220                         {
221                                 // ProjectData.SetProjectError(exception2);
222                                 Exception exception1 = exception2;
223                                 this.GHTSubTestUnexpectedExceptionCaught(exception1);
224                                 grid1 = null;
225                                 // ProjectData.ClearProjectError();
226                         }
227                         this.GHTSubTestEnd();
228                 }
229  
230                 #endregion
231
232                 private void Page_Load(object sender, System.EventArgs e) 
233                 {
234                         //Put user code to initialize the page here
235
236                         System.Web.UI.HtmlControls.HtmlForm frm = (HtmlForm)this.FindControl("Form1");
237                         GHTTestBegin(frm);
238
239                         DataGridTest("GhtSubTest1", c_bounded(""));
240                         DataGridTest("GhtSubTest2", c_button(""));
241                         DataGridTest("GhtSubTest3", c_edit(""));
242                         DataGridTest("GhtSubTest4", c_hyper_link(""));
243                         DataGridTest("GhtSubTest5", c_template(""));
244                         DataGridTest("GhtSubTest6", c_bounded("ID"));
245                         DataGridTest("GhtSubTest7", c_button("ID"));
246                         DataGridTest("GhtSubTest8", c_edit("ID"));
247                         DataGridTest("GhtSubTest9", c_hyper_link("ID"));
248                         DataGridTest("GhtSubTest10", c_template("ID"));
249                         DataGridTest("GhtSubTest11", c_bounded("test string"));
250                         DataGridTest("GhtSubTest12", c_button("test string"));
251                         DataGridTest("GhtSubTest13", c_edit("test string"));
252                         DataGridTest("GhtSubTest14", c_hyper_link("test string"));
253                         DataGridTest("GhtSubTest15", c_template("test string"));
254
255                         GHTTestEnd();
256                 }
257         }
258 }