{\r
DetailsViewCommandEventArgs args = e as DetailsViewCommandEventArgs;\r
if (args != null) {\r
- ProcessCommand (args);\r
+ bool causesValidation = false;\r
+ IButtonControl button = args.CommandSource as IButtonControl;\r
+ if (button != null && button.CausesValidation) {\r
+ Page.Validate (button.ValidationGroup);\r
+ causesValidation = true;\r
+ }\r
+ ProcessCommand (args, causesValidation);\r
return true;\r
}\r
return base.OnBubbleEvent (source, e);\r
}\r
\r
- void ProcessCommand (DetailsViewCommandEventArgs args) {\r
+ void ProcessCommand (DetailsViewCommandEventArgs args, bool causesValidation) {\r
OnItemCommand (args);\r
- ProcessEvent (args.CommandName, args.CommandArgument as string);\r
+ ProcessEvent (args.CommandName, args.CommandArgument as string, causesValidation);\r
}\r
\r
void IPostBackEventHandler.RaisePostBackEvent (string eventArgument)\r
arg = new CommandEventArgs (eventArgument.Substring (0, i), eventArgument.Substring (i + 1));\r
else\r
arg = new CommandEventArgs (eventArgument, null);\r
- ProcessCommand (new DetailsViewCommandEventArgs (this, arg));\r
+ ProcessCommand (new DetailsViewCommandEventArgs (this, arg), false);\r
}\r
- \r
- void ProcessEvent (string eventName, string param)\r
+\r
+ void ProcessEvent (string eventName, string param, bool causesValidation)\r
{\r
switch (eventName)\r
{\r
break;\r
\r
case DataControlCommands.UpdateCommandName:\r
- UpdateItem (param, true);\r
+ UpdateItem (param, causesValidation);\r
break;\r
\r
case DataControlCommands.CancelCommandName:\r
break;\r
\r
case DataControlCommands.InsertCommandName:\r
- InsertItem (true);\r
+ InsertItem (causesValidation);\r
break;\r
}\r
}\r
\r
void UpdateItem (string param, bool causesValidation)\r
{\r
- if (causesValidation && Page != null)\r
- Page.Validate ();\r
+ if (causesValidation && Page != null && !Page.IsValid)\r
+ return;\r
\r
if (CurrentMode != DetailsViewMode.Edit) throw new HttpException ();\r
\r
\r
void InsertItem (string param, bool causesValidation)\r
{\r
- if (causesValidation && Page != null)\r
- Page.Validate ();\r
+ if (causesValidation && Page != null && !Page.IsValid)\r
+ return;\r
\r
if (CurrentMode != DetailsViewMode.Insert) throw new HttpException ();\r
\r