Has anyone come across this before?...
I have a FormView with an EditTemplate and ItemTemplate.
The FormView is bound to a DataSource. The code behind does NO DataBind()
The FormView has an OnDataBound event.
For some reason this is triggered Twice!
The code for this event is...
Now because the routine is triggered twice my label lb_PerformedOn is set to double what it should be....
e.g. Tuesdays, Wednesdays, FridaysTuesdays, Wednesdays, Fridays
I can get around the issue by inserting a lb_PerformedOn.Text = "" before I start checking the values of the HiddenFields. But this does not explain why the event is being triggered twice.
Any explanations gratefully appreciated.
Mych
I've not failed! Just found 100 ways that don't work...yet!
I have a FormView with an EditTemplate and ItemTemplate.
The FormView is bound to a DataSource. The code behind does NO DataBind()
The FormView has an OnDataBound event.
For some reason this is triggered Twice!
The code for this event is...
Code:
Public Sub SetScheduleBindings(ByVal Sender As Object, ByVal e As eventArgs) Handles fv_TaskDetails.DataBound
If fv_TaskDetails.CurrentMode = FormViewMode.ReadOnly Then
Dim hd_PerfMon As HiddenField = fv_TaskDetails.FindControl("hd_PerfMon")
Dim hd_PerfTue As HiddenField = fv_TaskDetails.FindControl("hd_PerfTue")
Dim hd_PerfWed As HiddenField = fv_TaskDetails.FindControl("hd_PerfWed")
Dim hd_PerfThu As HiddenField = fv_TaskDetails.FindControl("hd_PerfThu")
Dim hd_PerfFri As HiddenField = fv_TaskDetails.FindControl("hd_PerfFri")
Dim hd_PerfSat As HiddenField = fv_TaskDetails.FindControl("hd_PerfSat")
Dim hd_PerfSun As HiddenField = fv_TaskDetails.FindControl("hd_PerfSun")
Dim lb_PerformedOn As Label = fv_TaskDetails.FindControl("lb_PerformedOn")
Dim hd_NTR As HiddenField = fv_TaskDetails.FindControl("hd_NTR")
Dim lb_NTR As Label = fv_TaskDetails.FindControl("lb_NTR")
If hd_PerfMon.Value = "True" Then
lb_PerformedOn.Text = lb_PerformedOn.Text & "Mondays, "
End If
If hd_PerfTue.Value = "True" Then
lb_PerformedOn.Text = lb_PerformedOn.Text & "Tuesdays, "
End If
If hd_PerfWed.Value = "True" Then
lb_PerformedOn.Text = lb_PerformedOn.Text & "Wednesdays, "
End If
If hd_PerfThu.Value = "True" Then
lb_PerformedOn.Text = lb_PerformedOn.Text & "Thursdays, "
End If
If hd_PerfFri.Value = "True" Then
lb_PerformedOn.Text = lb_PerformedOn.Text & "Fridays, "
End If
If hd_PerfSat.Value = "True" Then
lb_PerformedOn.Text = lb_PerformedOn.Text & "Saturdays, "
End If
If hd_PerfSun.Value = "True" Then
lb_PerformedOn.Text = lb_PerformedOn.Text & "Sundays, "
End If
lb_PerformedOn.Text = Left(lb_PerformedOn.Text, Len(lb_PerformedOn.Text) - 2)
If IsNothing(hd_NTR) = False Then
lb_NTR.Text = String.Format("{0:dd/MMM/yy hh:mm tt}", hd_NTR.Value.ToString)
End If
End If
If fv_TaskDetails.CurrentMode = FormViewMode.Edit Then
'Removed.....
End If
End Sub
Now because the routine is triggered twice my label lb_PerformedOn is set to double what it should be....
e.g. Tuesdays, Wednesdays, FridaysTuesdays, Wednesdays, Fridays
I can get around the issue by inserting a lb_PerformedOn.Text = "" before I start checking the values of the HiddenFields. But this does not explain why the event is being triggered twice.
Any explanations gratefully appreciated.
Mych
I've not failed! Just found 100 ways that don't work...yet!