- Home
- Forum
- ASP.NET Web Forms (Classic)
- Dynamically add template columns
Dynamically add template columns
- Nov 29, 2007 03:29 PM UTC
- Dec 3, 2007 12:05 PM UTC
Hi Friends,
How can i add dynamically add template columns to essential grid so that i can have a grid where all the rows are editable?
How can i add dynamically add template columns to essential grid so that i can have a grid where all the rows are editable?
SIGN IN To post a reply.
4 Replies
KG
Kathy Gray
November 29, 2007 08:07 PM UTC
Hi, I have just discovered how to do this, so I pass it on... You can create them similar to how you do with regular Gridview (see http://www.codeproject.com/useritems/create_template_columns.asp). Using that as an example, you would change "TemplateField bfield = new TemplateField();", to "GridColumnDescriptor bfield = new GridColumnDescriptor();", and "GridViewRow container = (GridViewRow)txtdata.NamingContainer;" to "GridCellTemplated Container = (GridCellTemplated) txtdata.NamingContainer"
ie: Use GridColumnDescriptor where it says TemplateField, and user GridCellTemplated where it says GridViewRow. Other than that, it's the same basic concept.
>Hi Friends,
How can i add dynamically add template columns to essential grid so that i can have a grid where all the rows are editable?
ie: Use GridColumnDescriptor where it says TemplateField, and user GridCellTemplated where it says GridViewRow. Other than that, it's the same basic concept.
>Hi Friends,
How can i add dynamically add template columns to essential grid so that i can have a grid where all the rows are editable?
KG
Kathy Gray
November 29, 2007 08:07 PM UTC
Hi, I have just discovered how to do this, so I pass it on... You can create them similar to how you do with regular Gridview (see http://www.codeproject.com/useritems/create_template_columns.asp). Using that as an example, you would change "TemplateField bfield = new TemplateField();", to "GridColumnDescriptor bfield = new GridColumnDescriptor();", and "GridViewRow container = (GridViewRow)txtdata.NamingContainer;" to "GridCellTemplated Container = (GridCellTemplated) txtdata.NamingContainer"
ie: Use GridColumnDescriptor where it says TemplateField, and user GridCellTemplated where it says GridViewRow. Other than that, it's the same basic concept.
>Hi Friends,
How can i add dynamically add template columns to essential grid so that i can have a grid where all the rows are editable?
ie: Use GridColumnDescriptor where it says TemplateField, and user GridCellTemplated where it says GridViewRow. Other than that, it's the same basic concept.
>Hi Friends,
How can i add dynamically add template columns to essential grid so that i can have a grid where all the rows are editable?
VS
Vinay Singh
November 30, 2007 06:39 AM UTC
Thanks kathy but i was looking forward to a VB.Net code for it and not C#.Can you help me with this?
RS
Rajarajeswari S
Syncfusion Team
December 3, 2007 12:05 PM UTC
Hi Vinay,
Thanks for using Syncfusion products:
You can have Template columns by creating separate Template Class. Please refer the below code snippet which illustrates to create template column:
If e.TableCellIdentity.Column.Name = "Column2" Then
Dim dropdown As Syncfusion.Web.UI.WebControls.Tools.DropDownCalendarControl = New DropDownCalendarControl()
'Here we adding the DropDownListBox programatically using ITemplate Interface
Dim mytemp As TemplateClass = New TemplateClass(dropdown)
e.TableCellIdentity.Column.EditItemTemplate = mytemp
End If
Public Class TemplateClass : Implements ITemplate
Private m_ctrlChildControl As Control = Nothing
Public Sub New(ByVal ctrlChildControl As Control)
m_ctrlChildControl = ctrlChildControl
End Sub
Public Sub InstantiateIn(ByVal container As Control) Implements ITemplate.InstantiateIn
container.Controls.Add(m_ctrlChildControl)
End Sub
End Class
Please refer the sample from the below link which illustrates the above:
http://websamples.syncfusion.com/samples/grid.web/5.2.0.25/i38780/main.htm
Please let me know if this helps you out.
Regards,
Raji
SIGN IN To post a reply.
- 4 Replies
- 3 Participants
-
VS Vinay Singh
- Nov 29, 2007 03:29 PM UTC
- Dec 3, 2007 12:05 PM UTC