Databind with ObjectDataSource using a method with params object[] -FWK 2.0

R

RenatoGuarilha

Hi,
I interested in use of ObjectDataSource to bind my POCO classes with
web controls.

But, I have been creating an interface framework in order to decrease
our development time. In this framework there is a generic execution
method responsible to instantiate any protected method in my
Transactional Classes. It is done by reflection.

This is it´s signature :

public Object exec(string pMethName, params Object[] p_prms)


I´ve been doing tests with a method in my ancestral service class
(Trasactional classes), who are able to retrieve all objects as a
collection. In this case it works very well, and I were able to
integrate with GridView without any problem.

<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
SelectMethod="exec"
TypeName="com.cmsolucoes.service.ServiceConsultaHospede">
<SelectParameters>
<asp:parameter DefaultValue="getAll" Name="pMethName"
Type="String" />
<asp:parameter DefaultValue="" Name="p_prms"
Type="Object" />
</SelectParameters>
</asp:ObjectDataSource>


Otherwise, If I try to do the same with another method, wich have a
parameter, It raises an exception.
{"Object of type 'System.Decimal' cannot be converted to type
'System.Object[]'."}

<asp:ObjectDataSource ID="ObjectDataSource2" runat="server"
SelectMethod="exec"
TypeName="com.cmsolucoes.service.ServiceConsultaHospede">
<SelectParameters>
<asp:parameter DefaultValue="findByPrimaryKey"
Name="pMethName" Type="String" />
<asp:ControlParameter ControlID="txtId" DefaultValue=""
Name="p_prms" PropertyName="Text"
Type="Decimal" />
</SelectParameters>
</asp:ObjectDataSource>

Method Signature:
protected virtual System.Object findByPrimaryKey(Object pk)


Has anyone some idea about this ?

Tks in advance,


Renato Guarilha
 

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,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top