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_FooterText
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 private DataGridColumn c_bounded(ListItemType tp, string text)
142 BoundColumn column1 = new BoundColumn();
143 column1.DataField = "ID";
144 this.setStyle(column1, tp);
145 this.setText(column1, tp, text);
149 private DataGridColumn c_button(ListItemType tp, string text)
151 ButtonColumn column1 = new ButtonColumn();
152 column1.DataTextField = "ID";
153 this.setStyle(column1, tp);
154 this.setText(column1, tp, text);
158 private DataGridColumn c_hyper_link(ListItemType tp, string text)
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);
168 private DataGridColumn c_edit(ListItemType tp, string text)
170 EditCommandColumn column1 = new EditCommandColumn();
171 column1.EditText = "Edit";
172 this.setStyle(column1, tp);
173 this.setText(column1, tp, text);
177 private DataGridColumn c_template(ListItemType tp, string text)
179 TemplateColumn column1 = new TemplateColumn();
180 column1.ItemTemplate = new DataGridColumn_FooterStyle.t_DBLitTemplate();
181 this.setStyle(column1, tp);
182 this.setText(column1, tp, text);
186 private void DataGridTest(string TestName, DataGridColumn c)
189 DataGrid dg = new DataGrid();
191 GHTSubTestBegin(TestName);
195 dg.DataSource = GHTTests.GHDataSources.DSDataTable();
196 dg.ShowFooter = true;
198 GHTActiveSubTest.Controls.Add(dg);
202 GHTSubTestUnexpectedExceptionCaught(ex);
210 private void Page_Load(object sender, System.EventArgs e)
212 //Put user code to initialize the page here
214 System.Web.UI.HtmlControls.HtmlForm frm = (HtmlForm)this.FindControl("Form1");
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"));