G
Greg Pyatt
Hi ASP.NET programmers,
I'm doing battle with a very tricky bug and it's mostly winning. I
hope someone out there can help with a few ideas...
I have a custom template column in a datagrid. In the template column
I've included an HtmlInputText object. The custom object uses
ITemplate.InstantiateIn.
The page loads just fine, however when I postback to the server with
an update to one of the textboxes, the database is updated correctly
but the returned page looks as though it was populated with the
Request.Form collection. It looks as though nothing happened between
the update postback and the page being returned.
Here is the code for the custom template colum object below:
------
Option Strict On
Option Explicit On
Public Class HTMLInputTextColumn
Implements ITemplate
Dim m_ID As String
Dim m_ColumnName As String
Public Sub New(ByVal ID As String)
m_ID = ID
Select Case m_ID
Case "txtNewBase"
m_ColumnName = "salary_increase"
Case "txtDollarIncrease"
m_ColumnName = "dollar_increase"
Case "txtPercentageIncrease"
m_ColumnName = "percentage_increase"
Case "txtLumpSum"
m_ColumnName = "lump_sum_increase"
End Select
End Sub
Overridable Overloads Sub InstantiateIn(ByVal container As
Control) Implements ITemplate.InstantiateIn
Dim txtTextbox As New HtmlInputText()
With txtTextbox
.Size = 6
.ID = m_ID
.Name = m_ID
.EnableViewState = True
End With
AddHandler txtTextbox.DataBinding, AddressOf Me.OnDataBinding
container.Controls.Add(txtTextbox)
End Sub
Private Sub OnDataBinding(ByVal sender As System.Object, ByVal e
As System.EventArgs)
Dim txtTextbox As HtmlInputText = CType(sender, HtmlInputText)
Dim container As DataGridItem =
CType(txtTextbox.NamingContainer, DataGridItem)
txtTextbox.Value = CType(container.DataItem,
DataRowView)(m_ColumnName).ToString()
End Sub
End Class
------
That's it! I know this one's a real trick, because I've looked all
over the internet for an answer and I'm still stuck. Thanks for any
help, it's greatly appreciated!
-Greg Pyatt
(e-mail address removed)
I'm doing battle with a very tricky bug and it's mostly winning. I
hope someone out there can help with a few ideas...
I have a custom template column in a datagrid. In the template column
I've included an HtmlInputText object. The custom object uses
ITemplate.InstantiateIn.
The page loads just fine, however when I postback to the server with
an update to one of the textboxes, the database is updated correctly
but the returned page looks as though it was populated with the
Request.Form collection. It looks as though nothing happened between
the update postback and the page being returned.
Here is the code for the custom template colum object below:
------
Option Strict On
Option Explicit On
Public Class HTMLInputTextColumn
Implements ITemplate
Dim m_ID As String
Dim m_ColumnName As String
Public Sub New(ByVal ID As String)
m_ID = ID
Select Case m_ID
Case "txtNewBase"
m_ColumnName = "salary_increase"
Case "txtDollarIncrease"
m_ColumnName = "dollar_increase"
Case "txtPercentageIncrease"
m_ColumnName = "percentage_increase"
Case "txtLumpSum"
m_ColumnName = "lump_sum_increase"
End Select
End Sub
Overridable Overloads Sub InstantiateIn(ByVal container As
Control) Implements ITemplate.InstantiateIn
Dim txtTextbox As New HtmlInputText()
With txtTextbox
.Size = 6
.ID = m_ID
.Name = m_ID
.EnableViewState = True
End With
AddHandler txtTextbox.DataBinding, AddressOf Me.OnDataBinding
container.Controls.Add(txtTextbox)
End Sub
Private Sub OnDataBinding(ByVal sender As System.Object, ByVal e
As System.EventArgs)
Dim txtTextbox As HtmlInputText = CType(sender, HtmlInputText)
Dim container As DataGridItem =
CType(txtTextbox.NamingContainer, DataGridItem)
txtTextbox.Value = CType(container.DataItem,
DataRowView)(m_ColumnName).ToString()
End Sub
End Class
------
That's it! I know this one's a real trick, because I've looked all
over the internet for an answer and I'm still stuck. Thanks for any
help, it's greatly appreciated!
-Greg Pyatt
(e-mail address removed)