the meaning of life and gridview's e.newValue

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hey all,
what is the purpose of e.NewValues inside the GridView1_RowUpdating routine?
i've seen examples where you findControl then assign that value to
e.NewValues, but that seems like an extra step.

thanks,
rodchar
 
rodchar said:
hey all,
what is the purpose of e.NewValues inside the GridView1_RowUpdating routine?
i've seen examples where you findControl then assign that value to
e.NewValues, but that seems like an extra step.

thanks,
rodchar

I use is to validate serverside. Here is an example

Sub EmailGrid_Updating(sender as object, e as GridViewUpdateEventargs)
'Check format of new data
dim bCancel as boolean = false
msg1.text = string.empty
dim strEmailAddress as string = string.empty
if not e.newvalues(0) is nothing then
strEmailAddress = Server.htmlencode(e.newvalues(0).tostring())
end if
BCancel= Regex.IsMatch(strEmailAddress,
"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-
Z]{2,4}|[0-9]{1,3})(\]?)$")
if BCancel then
dim strDate as string = string.empty
if not e.newvalues(2) is nothing then
strDate = Server.htmlencode(e.newvalues(2).tostring())
BCancel = IsDate(strDate)
if BCancel then
if (year(ctype(strDate,datetime)) < 2000) then
BCancel = false

end if
if not bCancel then msg1.text = "Invalid Date"
end if
else
msg1.text = "Invalid Email Address"
end if
e.Cancel = not bCancel
End sub
 
thank you i'll take a look.

vMike said:
rodchar said:
hey all,
what is the purpose of e.NewValues inside the GridView1_RowUpdating routine?
i've seen examples where you findControl then assign that value to
e.NewValues, but that seems like an extra step.

thanks,
rodchar

I use is to validate serverside. Here is an example

Sub EmailGrid_Updating(sender as object, e as GridViewUpdateEventargs)
'Check format of new data
dim bCancel as boolean = false
msg1.text = string.empty
dim strEmailAddress as string = string.empty
if not e.newvalues(0) is nothing then
strEmailAddress = Server.htmlencode(e.newvalues(0).tostring())
end if
BCancel= Regex.IsMatch(strEmailAddress,
"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-
Z]{2,4}|[0-9]{1,3})(\]?)$")
if BCancel then
dim strDate as string = string.empty
if not e.newvalues(2) is nothing then
strDate = Server.htmlencode(e.newvalues(2).tostring())
BCancel = IsDate(strDate)
if BCancel then
if (year(ctype(strDate,datetime)) < 2000) then
BCancel = false

end if
if not bCancel then msg1.text = "Invalid Date"
end if
else
msg1.text = "Invalid Email Address"
end if
e.Cancel = not bCancel
End sub
 
Back
Top