Odd ObjectDataSource Event Issue with Generic List of objects

Discussion in 'ASP .Net' started by fig000, Nov 30, 2007.

  1. fig000

    fig000 Guest

    Hi,

    I am new to C# and ObjectDataSources and have encountered what I
    think is a strange problem. I have a web page that has a formview on
    it. The formview is set to insert mode in the page load. The
    ObjectDataSource for the form has a procedure for inserting. Ths
    procedure adds the new record to the database using a tableadapter but
    it also adds the record to a generic list of business objects which
    has been placed into a session variable earlier in the life of the
    program.

    What is happening is that when I add the new record to the list it
    fires the ObjectDataSource's inserted event. This messes everything
    else up that comes after it; the program returns to the insert proc
    and the new business object I've that I tried to add to the list no
    longer is instantiated and has no value.

    If I take out the add to the list everything is fine and I can
    retreive values from OutputParameters and returnvalue. My question is:
    Why would adding a record to a generic list fire the
    ObjectDataSource's inserted event? The select procedure (which I
    assume is not fired in this case) binds a datatable converted from the
    same generic list of business objects (not the list itself) so I can't
    see how the changing this generic list would have any connection to
    the ObjectDataSource.

    Please forgive the redunancy of passing the new record id back
    through both OutputParameters and returnvalue; this was part of my
    experimentation.

    Anyway, any help would be appreciated. Here is the Insert Proc:

    public int InsertDevIssue(DateTime EntryDate, int EnteredBy, string
    Title, string RequestedBy, int Type, int Area, int Priority, int
    Status, int ModifiedBy, DateTime ModifiedDate, int AssignedTo, out int
    NewID)
    {

    DevissuesTableAdapters.devissueTableAdapter DevIssuesTblAdp =
    new DevissuesTableAdapters.devissueTableAdapter();
    Devissues.devissueDataTable DevIssuesTbl = new
    Devissues.devissueDataTable();
    Devissues.devissueRow dr = DevIssuesTbl.NewdevissueRow();
    dr.EntryDate = EntryDate;
    dr.EnteredBy = EnteredBy;
    dr.Title = Title;
    dr.RequestedBy = RequestedBy;
    dr.Type = Type;
    dr.Area = Area;
    dr.Priority = Priority;
    dr.Status = Status;
    dr.ModifiedBy = ModifiedBy;
    dr.ModifiedDate = ModifiedDate;
    dr.AssignedTo = AssignedTo;
    DevIssuesTbl.AdddevissueRow(dr);

    DevIssuesTblAdp.Update(DevIssuesTbl);
    NewID = dr.IssueID;

    List<clsDevIssues> DevissuesList =
    (List<clsDevIssues>)System.Web.HttpContext.Current.Session["clsDevIssues"];
    BusinessObjectsGeneric<clsDevIssues> BOG = new
    BusinessObjectsGeneric<clsDevIssues>();
    clsDevIssues newDevIssues = new clsDevIssues();

    BOG.UpdateObjectFromDB(newDevIssues, dr); //This fills the new
    object with the data
    DevissuesList.Add(newDevIssues); // This fires the ODS
    inserted event prematurely

    System.Web.HttpContext.Current.Session["clsDevIssues"] =
    DevissuesList;

    return dr.IssueID;

    }

    Thanks,
    Fig000
    fig000, Nov 30, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dotnet Gruven
    Replies:
    1
    Views:
    5,174
    Steven Cheng[MSFT]
    Sep 14, 2005
  2. Replies:
    2
    Views:
    4,070
  3. Michael Speer

    Odd behavior with odd code

    Michael Speer, Feb 16, 2007, in forum: C Programming
    Replies:
    33
    Views:
    1,086
    Richard Heathfield
    Feb 18, 2007
  4. David Thielen

    ObjectDataSource method as another ObjectDataSource

    David Thielen, Mar 21, 2006, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    241
    Steven Cheng[MSFT]
    Mar 23, 2006
  5. Ghistos
    Replies:
    1
    Views:
    166
    Bob Barrows [MVP]
    Jun 18, 2007
Loading...

Share This Page