Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / April 2008

Tip: Looking for answers? Try searching our database.

ObjectDataSource not calling BLL

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tides - 25 Apr 2008 10:26 GMT
My new page just won't fire the Update, Insert or Delete function on
the BLL.
I'm newish to ASP.NET and this may be a simple thing I have forgotten,
but its driving me up the wall.
I have other pages that work fine for this functionality.

Here is the ObjectDataSource:

   <asp:ObjectDataSource ID="StaffDetailsDataSource" runat="server"
       DeleteMethod="DeleteStaff" InsertMethod="InsertStaff"
       OldValuesParameterFormatString=""
SelectMethod="GetStaffByStaffID"
       TypeName="StaffBLL" UpdateMethod="UpdateStaff">
       <DeleteParameters>
           <asp:Parameter Name="ID" Type="Int32" />
       </DeleteParameters>
       <UpdateParameters>
           <asp:Parameter Name="ID" Type="Int32" />
           <asp:Parameter Name="CompanyID" Type="Int32" />
           <asp:Parameter Name="LoginName" Type="String" />
           <asp:Parameter Name="FirstName" Type="String" />
           <asp:Parameter Name="LastName" Type="String" />
           <asp:Parameter Name="ChargeRate" Type="Decimal" />
           <asp:Parameter Name="Position" Type="String" />
           <asp:Parameter Name="Gender" Type="String" />
           <asp:Parameter Name="Birthday" Type="DateTime" />
           <asp:Parameter Name="AccessLevel" Type="Int32" />
           <asp:Parameter Name="AlarmCode" Type="String" />
           <asp:Parameter Name="Notes" Type="String" />
           <asp:Parameter Name="AddressDetailsID" Type="Int32" />
           <asp:Parameter Name="BankDetailsID" Type="Int32" />
           <asp:Parameter Name="LoginEmailAddress" Type="String" />
           <asp:Parameter Name="Image" Type="Object" />
       </UpdateParameters>
       <SelectParameters>
           <asp:QueryStringParameter Name="ID" QueryStringField="ID"
Type="Int32" />
       </SelectParameters>
       <InsertParameters>
           <asp:Parameter Name="CompanyID" Type="Int32" />
           <asp:Parameter Name="LoginName" Type="String" />
           <asp:Parameter Name="FirstName" Type="String" />
           <asp:Parameter Name="LastName" Type="String" />
           <asp:Parameter Name="ChargeRate" Type="Decimal" />
           <asp:Parameter Name="Position" Type="String" />
           <asp:Parameter Name="Gender" Type="String" />
           <asp:Parameter Name="Birthday" Type="DateTime" />
           <asp:Parameter Name="AccessLevel" Type="Int32" />
           <asp:Parameter Name="AlarmCode" Type="String" />
           <asp:Parameter Name="Notes" Type="String" />
           <asp:Parameter Name="AddressDetailsID" Type="Int32" />
           <asp:Parameter Name="BankDetailsID" Type="Int32" />
           <asp:Parameter Name="LoginEmailAddress" Type="String" />
           <asp:Parameter Name="Image" Type="Object" />
       </InsertParameters>
   </asp:ObjectDataSource>

This is linked to a DetailsView that loads the data correctly.
Please let me know if you can help.
Stan - 26 Apr 2008 11:26 GMT
> My new page just won't fire the Update, Insert or Delete function on
> the BLL.
[quoted text clipped - 55 lines]
> This is linked to a DetailsView that loads the data correctly.
> Please let me know if you can help.

The problem is more likely to be with the DetailsView control rather
than the ObjectDataSource. It may work OK in ReadOnly mode but a lot
can go wrong in the Edit/Insert modes if it isn't set up properly.

Show us the mark-up for it and maybe we can help.
Stan - 26 Apr 2008 12:11 GMT
> My new page just won't fire the Update, Insert or Delete function on
> the BLL.
[quoted text clipped - 55 lines]
> This is linked to a DetailsView that loads the data correctly.
> Please let me know if you can help.

Forget my last post, I've just spotted the trouble. According to your
mark-up you haven't defined the sources for the parameters in the
Delete, Insert and Update methods.

You need to link them to the your DetailsView control. If you are
using VS2005 then the easiest way is to use the wizard for defining
them. Go to the Properties window and click on the Parameters for each
method. You will then be presented with a list of parameters awaiting
allocation.

The end result should be something like this:

       <UpdateParameters>
           <asp:ControlParameter ControlID="YourDetailsView"
Name="CompanyID" PropertyName="SelectedValue"
               Type="Int32" />

...
Tides - 28 Apr 2008 00:12 GMT
Thanks for the response. I have not used the ControlParameter before
and will give it a go, although in my other pages that work I do not
use them. Here is an example:

   <asp:ObjectDataSource ID="AssetDetailsDataSource" runat="server"
       SelectMethod="GetAssetByAssetID" TypeName="AssetsBLL"
       DeleteMethod="DeleteAsset"
       InsertMethod="InsertAsset" UpdateMethod="UpdateAsset" >
       <SelectParameters>
           <asp:QueryStringParameter Name="ID" QueryStringField="ID"
Type="Int32" />
       </SelectParameters>
       <DeleteParameters>
           <asp:Parameter Name="ID" Type="Int32" />
       </DeleteParameters>
       <UpdateParameters>
           <asp:Parameter Name="SectionID" Type="Int32" />
           <asp:Parameter Name="Description" Type="String" />
           <asp:Parameter Name="Number" Type="Int32" />
           <asp:Parameter Name="PurchaseDate" Type="DateTime" />
           <asp:Parameter Name="ReviewDate" Type="DateTime" />
           <asp:Parameter Name="Condition" Type="String" />
           <asp:Parameter Name="PurchasePrice" Type="Decimal" />
           <asp:Parameter Name="Notes" Type="String" />
           <asp:Parameter Name="DepreciationPercentage"
Type="Decimal" />
           <asp:Parameter Name="DepreciationMonths" Type="Int32" />
           <asp:Parameter Name="Image" Type="Object" />
           <asp:Parameter Name="ID" Type="Int32" />
           <asp:SessionParameter Name="CompanyID"
SessionField="CompanyID" Type="Int32" />
       </UpdateParameters>
       <InsertParameters>
           <asp:Parameter Name="SectionID" Type="Int32" />
           <asp:Parameter Name="Description" Type="String" />
           <asp:Parameter Name="Number" Type="Int32" />
           <asp:Parameter Name="PurchaseDate" Type="DateTime" />
           <asp:Parameter Name="ReviewDate" Type="DateTime" />
           <asp:Parameter Name="Condition" Type="String" />
           <asp:Parameter Name="PurchasePrice" Type="Decimal" />
           <asp:Parameter Name="Notes" Type="String" />
           <asp:Parameter Name="DepreciationPercentage"
Type="Decimal" />
           <asp:Parameter Name="DepreciationMonths" Type="Int32" />
           <asp:Parameter Name="Image" Type="Object" />
           <asp:SessionParameter Name="CompanyID"
SessionField="CompanyID" Type="Int32" />
       </InsertParameters>
   </asp:ObjectDataSource>
   <asp:DetailsView
       ID="dvDetails"
       runat="server"
       AutoGenerateRows="False"
       DataSourceID="AssetDetailsDataSource"
       DataKeyNames="ID"
       width="75%">

And just for reference, here is the top of the details view for
StaffDetails:

   <asp:DetailsView
       ID="dvDetails"
       runat="server"
       AutoGenerateRows="False"
       DataSourceID="StaffDetailsDataSource"
       DataKeyNames="ID"
       Width="75%">

The select is firing so the connection to the BLL, I would assume, is
fine in terms of namespace declaration.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.