2 // System.Web.UI.WebControls.TemplateColumn.cs
5 // Gaurav Vaish (gvaish@iitk.ac.in)
6 // Andreas Nahr (ClassDevelopment@A-SoftTech.com)
8 // (C) Gaurav Vaish (2002)
9 // (C) 2003 Andreas Nahr
13 // Permission is hereby granted, free of charge, to any person obtaining
14 // a copy of this software and associated documentation files (the
15 // "Software"), to deal in the Software without restriction, including
16 // without limitation the rights to use, copy, modify, merge, publish,
17 // distribute, sublicense, and/or sell copies of the Software, and to
18 // permit persons to whom the Software is furnished to do so, subject to
19 // the following conditions:
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35 using System.ComponentModel;
\r
37 using System.Web.UI;
\r
39 namespace System.Web.UI.WebControls
\r
41 public class TemplateColumn : DataGridColumn
\r
43 private ITemplate editItemTemplate;
\r
44 private ITemplate footerTemplate;
\r
45 private ITemplate headerTemplate;
\r
46 private ITemplate itemTemplate;
\r
48 public TemplateColumn(): base()
\r
52 [DefaultValue (null), Browsable (false)]
53 [PersistenceMode (PersistenceMode.InnerProperty), TemplateContainer (typeof (DataGridItem))]
54 [WebSysDescription ("The template that is used to build that are being edited rows for this column.")]
\r
55 public virtual ITemplate EditItemTemplate
\r
59 return editItemTemplate;
\r
63 editItemTemplate = value;
\r
68 [DefaultValue (null), Browsable (false)]
69 [PersistenceMode (PersistenceMode.InnerProperty), TemplateContainer (typeof (DataGridItem))]
70 [WebSysDescription ("The template that is used to build the footer for this column.")]
\r
71 public virtual ITemplate FooterTemplate
\r
75 return footerTemplate;
\r
79 footerTemplate = value;
\r
84 [DefaultValue (null), Browsable (false)]
85 [PersistenceMode (PersistenceMode.InnerProperty), TemplateContainer (typeof (DataGridItem))]
86 [WebSysDescription ("The template that is used to build the header for this column.")]
\r
87 public virtual ITemplate HeaderTemplate
\r
91 return headerTemplate;
\r
95 headerTemplate = value;
\r
100 [DefaultValue (null), Browsable (false)]
101 [PersistenceMode (PersistenceMode.InnerProperty), TemplateContainer (typeof (DataGridItem))]
102 [WebSysDescription ("The template that is used to build rows for this column.")]
\r
103 public virtual ITemplate ItemTemplate
\r
107 return itemTemplate;
\r
111 itemTemplate = value;
\r
116 public override void InitializeCell(TableCell cell, int columnIndex, ListItemType itemType)
\r
118 base.InitializeCell(cell, columnIndex, itemType);
\r
119 ITemplate toRender = null;
\r
122 case ListItemType.Header: toRender = headerTemplate;
\r
124 case ListItemType.Footer: toRender = footerTemplate;
\r
126 case ListItemType.SelectedItem:
127 case ListItemType.AlternatingItem:
128 case ListItemType.Item: toRender = itemTemplate;
\r
130 case ListItemType.EditItem:
131 toRender = (editItemTemplate != null ? editItemTemplate : itemTemplate);
\r
134 if(toRender != null)
\r
136 cell.Text = String.Empty;
\r
137 toRender.InstantiateIn(cell);
\r