I have a ListView that populates and displays a user's data (via a profile system in VWD 2008) during Page_Load
and also when I go from the EditItemTemplate
to the ItemTemplate
.
When I go to the edit screen again, my DropDownList and RadioButtonList controls display the first items in the corresponding tables instead of the correct profile values.
I don't understand why the controls populate correctly the first and second times but not on the third time (that's right, the third time is NOT a charm).
Can someone can help me understand how to solve this problem?
ItemTemplate:
<asp:DropDownList ID="ddlTState" AppendDataBoundItems="True"
DataSourceID="srcState" DataTextField="StateName" DataValueField="StateName"
Enabled="False" TabIndex="125" runat="server" />
EditItemTemplate:
<asp:DropDownList ID="ddlEState" AppendDataBoundItems="true"
DataSourceID="srcState" DataTextField="StateName"
DataValueField="StateName" TabIndex="125" runat="server">
<asp:ListItem Text="--State--" Value="" />
VB code behind
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
lsv = Util.FindChild(Me, "lsvProfile")
'If Not IsPostBack Then
ddl = Util.FindChild(lsv, "ddlEState") 'Util.FindChild = my version of FindControl
If ddl IsNot Nothing Then ddl.SelectedValue = Profile.State
ddl = Util.FindChild(lsv, "ddlTState")
If ddl IsNot Nothing Then ddl.SelectedValue = Profile.State
'End If
End Sub