ObjectDataSource not calling BLL

  • Thread starter Thread starter Tides
  • Start date Start date
T

Tides

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.
 
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.

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.
 
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.

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" />

...
 
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.
 
Back
Top