• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 348
  • Last Modified:

Bound Column or Template Column

After reading, I still don't understand the differences bettween a bound column and a template column.

Could someone please name a few key differences in these two types of columns?

Thanks in advance,
0
Weller0123
Asked:
Weller0123
4 Solutions
 
NetDeveloperCommented:
basically, if you want to have <html> elements (runat=server or not ) and or <asp: tags inside a column of your DataGrid you have to use template columns.

bound colums are, instead ok, when u don't want to include in your Grid those elements

you can also use just one template colum to have a datagrid with any kind of html layout.
0
 
davidlars99Commented:
this is code which make "BoundColumn" work

Public Class BoundColumn
      Inherits DataGridColumn

      ' Methods
      Shared Sub New()
      Public Sub New()
      Protected Overridable Function FormatDataValue(ByVal dataValue As Object) As String
      Public Overrides Sub Initialize()
      Public Overrides Sub InitializeCell(ByVal cell As TableCell, ByVal columnIndex As Integer, ByVal itemType As ListItemType)
      Private Sub OnDataBindColumn(ByVal sender As Object, ByVal e As EventArgs)

      ' Properties
      <WebCategory("Data"), WebSysDescription("BoundColumn_DataField"), DefaultValue("")> _
      Public Overridable Property DataField As String
      <DefaultValue(""), WebCategory("Behavior"), WebSysDescription("BoundColumn_DataFormatString")> _
      Public Overridable Property DataFormatString As String
      <WebSysDescription("BoundColumn_ReadOnly"), WebCategory("Behavior"), DefaultValue(False)> _
      Public Overridable Property [ReadOnly] As Boolean

      ' Fields
      Private boundField As String
      Private boundFieldDesc As PropertyDescriptor
      Private boundFieldDescValid As Boolean
      Private formatting As String
      Public Shared ReadOnly thisExpr As String
End Class



and this is the for "TemplateColumn"

Public Class TemplateColumn
      Inherits DataGridColumn

      ' Methods
      Public Sub New()
      Public Overrides Sub InitializeCell(ByVal cell As TableCell, ByVal columnIndex As Integer, ByVal itemType As ListItemType)

      ' Properties
      <DefaultValue(CType(Nothing,String)), TemplateContainer(GetType(DataGridItem)), Browsable(False), WebSysDescription("TemplateColumn_EditItemTemplate"), PersistenceMode(PersistenceMode.InnerProperty)> _
      Public Overridable Property EditItemTemplate As ITemplate
      <WebSysDescription("TemplateColumn_FooterTemplate"), DefaultValue(CType(Nothing,String)), PersistenceMode(PersistenceMode.InnerProperty), TemplateContainer(GetType(DataGridItem)), Browsable(False)> _
      Public Overridable Property FooterTemplate As ITemplate
      <TemplateContainer(GetType(DataGridItem)), WebSysDescription("TemplateColumn_HeaderTemplate"), PersistenceMode(PersistenceMode.InnerProperty), Browsable(False), DefaultValue(CType(Nothing,String))> _
      Public Overridable Property HeaderTemplate As ITemplate
      <TemplateContainer(GetType(DataGridItem)), DefaultValue(CType(Nothing,String)), PersistenceMode(PersistenceMode.InnerProperty), Browsable(False), WebSysDescription("TemplateColumn_ItemTemplate")> _
      Public Overridable Property ItemTemplate As ITemplate

      ' Fields
      Private editItemTemplate As ITemplate
      Private footerTemplate As ITemplate
      Private headerTemplate As ITemplate
      Private itemTemplate As ITemplate
End Class

0
 
RejojohnyCommented:
when u want the grid to be used just for displaying data and not interactive i.e. no textboxes, checkbox etc .. then u will use bound columns for those columns
but when u want to accept data, ask user to input data using a dropdown etc .. then u will have to use template columns and then add these webcontrols that u require within these template columns ..

take the example of an "inbox" page in hotmail or for that matter most of the mail sites .. the list of mails could be displayed by using a datagrid with the first column where there is checkbox to select the mail, u would have to use a template column and add a checkbox within it .. but for the other columns like the description, date etc, u could just use a bound column
0
 
Ramesh SrinivasTechnical ConsultantCommented:
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now