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

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
 
J

Just Me

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)
 
R

RosH

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top