Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Binding Data to a dynamically created textbox

Status
Not open for further replies.

ac11nyc

Programmer
Oct 1, 2003
94
US
Does anyone know how i can bind data to a textbox that i dynamically created inside a datagrid??

This creates the textbox inside the datagrid:

Dim tcl As New TemplateColumn
tcl.HeaderTemplate = New DataGridTemplate(ListItemType.Header, "Sun")
tcl.ItemTemplate = New DataGridTemplate(ListItemType.Item, "Sunday")
tcl.EditItemTemplate = New DataGridTemplate(ListItemType.EditItem, "Sun")
tcl.FooterTemplate = New DataGridTemplate(ListItemType.Footer, "Sun")
TasksDG.Columns.Add(tcl)

This is the class that setups the textbox to be created:

Public Class DataGridTemplate
Implements ITemplate
Dim TemplateType As ListItemType
Dim columnName As String

Sub New(ByVal type As ListItemType, ByVal ColName As String)
TemplateType = type
columnName = ColName
End Sub

Public Sub InstantiateIn(ByVal container As System.Web.UI.Control) Implements System.Web.UI.ITemplate.InstantiateIn
Dim lc As New Literal
Select Case TemplateType
Case ListItemType.Header
lc.Text = "<B>" & columnName & "</B>"
container.Controls.Add(lc)
Case ListItemType.Item
Dim tb As New TextBox
tb.Text = ""
tb.Width = tb.Width.Pixel(25)
container.Controls.Add(tb)
End Select
End Sub
End Class
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top