Please I need help!!
I have seen many posts, but never found a solution. My basic problem is accessing the controls inside the formview when mode is being changed. As I understand, you can only access currentMode's controls. So lets say I want to access edit mode's control and I am in readonly mode, in that case what I am doing is during mode-changed event, i am trying to access a control in edit mode. But the problem is, although it detects the mode has been changed to edit, but it still has readonly mode's controls in memory, instead of edit modes, and edit mode's control do not seem to be available till the page is rendered. So they are only available during page unload event (not even at prerender), when it becomes useless to access and modify control property, because it has already been rendered.
So does anybody know the solution to the problem? I will appreciate if you could help in this regard.
Following is a function in which I am trying to access a couple of controls and I am calling it during mode-changed event:
Protected Sub addValueAttributeToPasswordTextBoxes()
Dim cntrl1 As Control
If fvContactDetail.CurrentMode = FormViewMode.Edit Then
For Each cntrl1 In fvContactDetail.Row.Controls
Dim SSN As TextBox = CType(cntrl1.FindControl("SSN"), TextBox)
Dim SSN_PWD As TextBox = CType(cntrl1.FindControl("SSN_PWD"), TextBox)
Dim SSN_Confirm_PWD As TextBox = CType(cntrl1.FindControl("SSN_Confirm_PWD"), TextBox)
If Not (SSN Is Nothing Or SSN_PWD Is Nothing Or SSN_Confirm_PWD Is Nothing) Then
Dim SSN_PWD_Value As String = SSN_PWD.Attributes.Item("Value")
Dim SSN_PWD_Confirm_Value As String = SSN_Confirm_PWD.Attributes.Item("Value")
If SSN_PWD_Value Is Nothing Then
SSN_PWD.Attributes.Item("Value") = SSN.Text
If SSN_PWD_Confirm_Value Is Nothing Then
SSN_Confirm_PWD.Attributes.Item("Value") = SSN.Text
SSN = Nothing
SSN_PWD = Nothing