Page.Load event fired before RowCommand or OnClick command cause me a problem with a Formview Default Mode
Posted on 2006-06-03
I have a gridview control that is displaying a WebUserControl that is containing a FormView control to display or edit the details of the selected item.
I have also a button to insert a new record in the database.
I have created 2 public property to help me control the way to display the formview and when the data has been updated to refresh the GridView.
Public Event DataUpdated As EventHandler
Public DefaultDisplayMode As String
Protected Overridable Sub OnDataUpdated(ByVal e As EventArgs)
RaiseEvent DataUpdated(Me, e)
The problem I have is with the DefaultDisplayMode.
When I click the button, I want to display the formview in Insert mode. So in the Page.Load of the WebUserControl, Iput the following code:
WUC Page.Load Sub:
If DefaultDisplayMode = "Insert" Then
fvTelephoneInfos.DefaultMode = FormViewMode.Insert
CType(fvTelephoneInfos.FindControl("EquipmentTypeLabel"), Label).Text = "Telephone"
Protected Sub btnAddConfiguration_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAddConfiguration.Click
' Dim strCommand As String
Dim strCustID As String
strCustID = Session("CustID")
Select Case ddlEquipmentType.SelectedValue
WucTelephoneDetails1.DefaultDisplayMode = "Insert"
WucTelephoneDetails1.Visible = True
The problem, is that the WebUserControl Page.Load event is lunched before the Button OnClick event or Gridview RowCommand, so the DefaultDisplayMode is not yet initialized.
Is there a way to tels the WebUserControl that the DefaultDisplayMode property has changed, or processed the WebUserControl Page.Load event after the Onclick and RowCommand events.