Change of new values during the (FormView_Updating) event does not work

  • Thread starter Thread starter RosH
  • Start date Start date
R

RosH

I cannot understand what is wrong with the following code. All I want
to do is to change certain values of a DateTime column during FormView
updating event. Right now this event handler returns Null values to
the Database. Looking for expert advice.

Protected Sub FormView1_ItemUpdating(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.FormViewUpdatedEventArgs) Handles
FormView1.ItemUpdated

Dim PassOutYearDDL As DropDownList =
FormView1.FindControl("PassOutYearDDL")
Dim PassOutDate1 As DateTime =
DateTime.ParseExact(PassOutYearDDL.SelectedValue.ToString, "yyyy",
Nothing)
e.NewValues.Remove("PassOutYear")
e.NewValues.Add("PassOutYear", PassOutDate1.ToString)

End Sub
 
I think this only works when you are bound to a datasource. Is this the case
?


'//Your Code
#1 - Dim PassOutYearDDL As DropDownList =
FormView1.FindControl("PassOutYearDDL")
#2 - Dim PassOutDate1 As DateTime =
DateTime.ParseExact(PassOutYearDDL.SelectedValue.ToString, "yyyy",Nothing)

#4 - e.NewValues.Remove("PassOutYear")
#5 - e.NewValues.Add("PassOutYear", PassOutDate1.ToString)
 
Thank you for the reply,

All I wanted to do is to change certain values just before update to a
database, using code. If you have any "how-to" reference of doing it,
please send me.
 
Back
Top