Odd ObjectDataSource Event Issue with Generic List of objects

F

fig000

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
 

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,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top