Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 13th, 2012  |  syntax: None  |  size: 1.31 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Debugging GridView / ObjectDataSource events
  2. <asp:ObjectDataSource ID="Things" runat="server"
  3.     TypeName="BLL.Thing"
  4.     UpdateMethod="UpdateThing"
  5.     OnUpdating="Things_Updating"
  6.     OnUpdated="Things_Updated">
  7.     <UpdateParameters>
  8.         <asp:SessionParameter
  9.             Name="userContext"
  10.             SessionField="UserContext"
  11.             Type="Object" />
  12.         <asp:Parameter Name="thing" Type="Object" />
  13.     </UpdateParameters>
  14. </asp:ObjectDataSource>
  15.        
  16. <EditItemTemplate>
  17.     <asp:ImageButton ID="ImageButton_Save" runat="server"
  18.         CommandName="Update"
  19.         SkinID="Save"
  20.         CausesValidation="false"
  21.         CommandArgument='<%# Eval("Id") %>' />
  22.     <asp:ImageButton ID="ImageButton_Cancel" runat="server"
  23.         CommandName="Cancel"
  24.         SkinID="Cancel"
  25.         CausesValidation="false" />
  26. </EditItemTemplate>
  27.        
  28. protected void Things_Updating(object sender, ObjectDataSourceMethodEventArgs e)
  29. {
  30.     e.InputParameters["thing"] = _theThing;
  31. }
  32.        
  33. protected void gridThings_RowUpdating(object sender, GridViewUpdateEventArgs e)
  34. {
  35.     e.NewValues.Add("thing", _theThing);
  36. }
  37.        
  38. protected void myGridView_RowUpdating(Object sender, GridViewUpdateEventArgs e)
  39. {
  40.     e.Cancel = true;
  41. }
  42.        
  43. private void myObjectDataSource_Updating(object source, ObjectDataSourceMethodEventArgs e)
  44. {
  45.     e.Cancel = true;
  46. }