Dataview et ObjectDataSource.Select
Bonjour
J'ai du mal à binder mon ObjectDataSource avec ma Gridview.
Ma méthode Select retourne bien un dataset (j'ai éssayé avec datatable et dataview aussi).
Mais lors de l'exécution je me retrouve avec un message d'erreur comme quoi l'objet ne comprend pas de constructeurs: Voici les codes.
Merci d 'avance pour votre aide
PageASPX:
Code:
1 2 3 4 5 6 7 8 9 10
|
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" OldValuesParameterFormatString="original_{0}"
SelectMethod="GetAllServers" TypeName="Factory.ServerFactory" >
</asp:ObjectDataSource>
</div>
<asp:GridView ID="GridView1" runat="server" DataSourceID="ObjectDataSource1">
</asp:GridView>
</form> |
Code renvoyant mon Dataview
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
<System.ComponentModel.DataObjectMethodAttribute _
(System.ComponentModel.DataObjectMethodType.Select, True)> _
Public Function GetAllServers() As DataView
Dim dbDAO As New DBServerDAO()
Dim dt As New DataTable("Servers")
Dim dr As DataRow
Dim colId = New DataColumn("Id", GetType(Int16))
dt.Columns.Add(colId)
Dim colCn = New DataColumn("Cn", GetType(String))
dt.Columns.Add(colCn)
Dim colDesc = New DataColumn("description", GetType(String))
dt.Columns.Add(colDesc)
Dim colType = New DataColumn("type", GetType(String))
dt.Columns.Add(colType)
For Each srv As DBServerDAO In dbDAO.GetAllServerOnlyFromDB()
dr = dt.NewRow()
dr("Id") = srv.Id
dr("Cn") = srv.Cn
dr("description") = srv.Description
dr("type") = srv.Type
dt.Rows.Add(dr)
Next
Return dt.DefaultView
End Function |
Message d'érreur:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
No parameterless constructor defined for this object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.MissingMethodException: No parameterless constructor defined for this object.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[MissingMethodException: No parameterless constructor defined for this object.]
System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck) +0
System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache) +103
System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache) +268
System.Activator.CreateInstance(Type type, Boolean nonPublic) +66
System.Web.UI.WebControls.ObjectDataSourceView.InvokeMethod(ObjectDataSourceMethod method, Boolean disposeInstance, Object& instance) +127
System.Web.UI.WebControls.ObjectDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1960
System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +17
System.Web.UI.WebControls.DataBoundControl.PerformSelect() +149
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +70
System.Web.UI.WebControls.GridView.DataBind() +4
System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82
System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +69
System.Web.UI.Control.EnsureChildControls() +87
System.Web.UI.Control.PreRenderRecursiveInternal() +50
System.Web.UI.Control.PreRenderRecursiveInternal() +170
System.Web.UI.Control.PreRenderRecursiveInternal() +170
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2041 |