3 // Rafael Mizrahi <rafim@mainsoft.com>
4 // Erez Lotan <erezl@mainsoft.com>
5 // Vladimir Krasnov <vladimirk@mainsoft.com>
8 // Copyright (c) 2002-2005 Mainsoft Corporation.
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:
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
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.
32 using System.Collections;
35 using System.Web.UI.WebControls;
36 using System.Web.UI.HtmlControls;
38 namespace GHTTests.System_Web_dll.System_Web_UI_WebControls
40 public class DataGridColumn_SortExpression
43 #region Web Form Designer generated code
44 override protected void OnInit(EventArgs e)
47 // CODEGEN: This call is required by the ASP.NET Web Form Designer.
49 InitializeComponent();
54 /// Required method for Designer support - do not modify
55 /// the contents of this method with the code editor.
57 private void InitializeComponent()
59 this.Load += new System.EventHandler(this.Page_Load);
63 #region "Template Classes"
64 public class t_DBLitTemplate : ITemplate
66 public void InstantiateIn(Control container)
68 Literal literal1 = new Literal();
69 literal1.Text = "<div>";
70 literal1.DataBinding += new EventHandler(this.BindData);
71 container.Controls.Add(literal1);
73 public void BindData(object sender, EventArgs e)
75 Literal literal1 = (Literal) sender;
76 DataGridItem item1 = (DataGridItem) literal1.NamingContainer;
77 literal1.Text = DataBinder.Eval(item1.DataItem, "Name") + "</div>";
80 public class t_EmptyLitTemplate : ITemplate
82 public void InstantiateIn(Control container)
84 Literal literal1 = new Literal();
86 container.Controls.Add(literal1);
89 public class t_PlainTextLitTemplate : ITemplate
91 public void InstantiateIn(Control container)
93 Literal literal1 = new Literal();
94 literal1.Text = "Plain text template create at run time";
95 container.Controls.Add(literal1);
98 public class t_HtmlLitTemplate : ITemplate
100 public void InstantiateIn(Control container)
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);
107 public class t_ControlLitTemplate : ITemplate
109 public void InstantiateIn(Control container)
111 HtmlInputButton button1 = new HtmlInputButton();
112 button1.Value = "Control template";
113 container.Controls.Add(button1);
118 #region "DataGrid creation functions"
119 private void setText(DataGridColumn c, ListItemType tp, string text)
123 case ListItemType.Header:
128 case ListItemType.Footer:
136 private void setStyle(DataGridColumn c, ListItemType tp)
140 case ListItemType.Header:
142 c.HeaderStyle.VerticalAlign = VerticalAlign.Top;
143 c.HeaderStyle.HorizontalAlign = HorizontalAlign.Right;
144 c.HeaderStyle.Wrap = false;
147 case ListItemType.Footer:
149 c.FooterStyle.VerticalAlign = VerticalAlign.Top;
150 c.FooterStyle.HorizontalAlign = HorizontalAlign.Right;
151 c.FooterStyle.Wrap = false;
154 case ListItemType.Item:
156 c.ItemStyle.VerticalAlign = VerticalAlign.Top;
157 c.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
158 c.ItemStyle.Wrap = false;
164 private DataGridColumn c_bounded(string se)
166 BoundColumn column1 = new BoundColumn();
167 column1.DataField = "ID";
168 column1.SortExpression = se;
173 private DataGridColumn c_button(string se)
175 ButtonColumn column1 = new ButtonColumn();
176 column1.DataTextField = "ID";
177 column1.SortExpression = se;
181 private DataGridColumn c_hyper_link(string se)
183 HyperLinkColumn column1 = new HyperLinkColumn();
184 column1.DataTextField = "ID";
185 column1.NavigateUrl = "http://www.google.com";
186 column1.SortExpression = se;
190 private DataGridColumn c_edit(string se)
192 EditCommandColumn column1 = new EditCommandColumn();
193 column1.EditText = "Edit";
194 column1.SortExpression = se;
198 private DataGridColumn c_template(string se)
200 TemplateColumn column1 = new TemplateColumn();
201 column1.ItemTemplate = new DataGridColumn_SortExpression.t_DBLitTemplate();
202 column1.SortExpression = se;
206 private void DataGridTest(string TestName, DataGridColumn c)
208 DataGrid grid1 = new DataGrid();
209 this.GHTSubTestBegin(TestName);
212 grid1.Columns.Add(c);
213 grid1.DataSource = GHTTests.GHDataSources.DSDataTable();
214 grid1.ShowFooter = true;
216 base.GHTActiveSubTest.Controls.Add(grid1);
217 this.GHTSubTestAddResult(grid1.Columns[0].SortExpression);
219 catch (Exception exception2)
221 // ProjectData.SetProjectError(exception2);
222 Exception exception1 = exception2;
223 this.GHTSubTestUnexpectedExceptionCaught(exception1);
225 // ProjectData.ClearProjectError();
227 this.GHTSubTestEnd();
232 private void Page_Load(object sender, System.EventArgs e)
234 //Put user code to initialize the page here
236 System.Web.UI.HtmlControls.HtmlForm frm = (HtmlForm)this.FindControl("Form1");
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"));