No parameterless constructor defined for this object.
-
Hi Guru's Im using ObjectDataSource for filling up the GridView, I'm just moving in on using objectDataSource, I find it handy since it trims up my code. After placing the requirement I'm encountering this issue No parameterless constructor defined for this object. Please let me know what when wrong? Regards Dom
-
Hi Guru's Im using ObjectDataSource for filling up the GridView, I'm just moving in on using objectDataSource, I find it handy since it trims up my code. After placing the requirement I'm encountering this issue No parameterless constructor defined for this object. Please let me know what when wrong? Regards Dom
The class doesn't have a zero parameter constructor. Some object that you are using requires a zero parameter constructor (even if it doesn't use it).
Deja View - the feeling that you've seen this post before.
-
Hi Guru's Im using ObjectDataSource for filling up the GridView, I'm just moving in on using objectDataSource, I find it handy since it trims up my code. After placing the requirement I'm encountering this issue No parameterless constructor defined for this object. Please let me know what when wrong? Regards Dom
Here's the deal. Any serializable object must have a parameterless constuctor. For the Object Oriented beginner that means. Class MyDataOject { public MyDataOject() { //parameterless consturctor } } This is so that the object can be serialized to XML. Also you can not not have read only properties for the same reason. If a property is read only you can't recreate the object from xml. The objectDataSource probably serializes your class behind the scenes.
I didn't get any requirements for the signature
-
Here's the deal. Any serializable object must have a parameterless constuctor. For the Object Oriented beginner that means. Class MyDataOject { public MyDataOject() { //parameterless consturctor } } This is so that the object can be serialized to XML. Also you can not not have read only properties for the same reason. If a property is read only you can't recreate the object from xml. The objectDataSource probably serializes your class behind the scenes.
I didn't get any requirements for the signature
Hmm basically I doing a layman work which is trying to convert my DAL (data access layer) functions to objectDataSource properties, the function I'm calling accepts one argument which sometimes can be null / 0 since its optional. Below is my function as well as the DAL that it calls
Public Function fill(Optional ByVal orderID As Integer = 0) As DataTable Dim cmd As SqlCommand cmd = New SqlCommand Dim da As SqlDataAdapter da = New SqlDataAdapter Dim dt As DataTable Try dt = New DataTable cmd.Connection = _SQLConnection cmd.CommandType = CommandType.StoredProcedure cmd.CommandText = "nw_spSelectOrders" cmd.Transaction = _SQLTransaction If Not orderID.Equals(0) Then cmd.Parameters.Add(New SqlParameter("@orderID", SqlDbType.Int)) cmd.Parameters("@orderID").Direction = ParameterDirection.Input cmd.Parameters("@orderID").Value = orderID End If da.SelectCommand = cmd da.Fill(dt) If Not dt.Rows.Count > 0 Then Throw New Exception("no record") Else Return dt End If Catch ex As Exception Throw New Exception(ex.Message) Finally cmd.Dispose() da.Dispose() End Try End Function
SP for the function above: 0 - returns all dataSET ANSI_NULLS ON SET QUOTED_IDENTIFIER ON GO alter PROCEDURE nw_spSelectOrders ( @orderID int = 0 ) as begin Select o.orderID, od.quantity, od.unitprice, od.unitprice from orders as o left outer join [order details] as od on o.orderid = od.orderid where case when @orderID = 0 then 'selected' else case when o.orderID = @orderID then 'selected' else 'not selected' end end= 'selected' end
Whats wrong with passing 0? when I explicitly place orderID number I get result but passing 0 nada.. Please advice Thanks Guys -- modified at 20:49 Tuesday 11th September, 2007 -
Hmm basically I doing a layman work which is trying to convert my DAL (data access layer) functions to objectDataSource properties, the function I'm calling accepts one argument which sometimes can be null / 0 since its optional. Below is my function as well as the DAL that it calls
Public Function fill(Optional ByVal orderID As Integer = 0) As DataTable Dim cmd As SqlCommand cmd = New SqlCommand Dim da As SqlDataAdapter da = New SqlDataAdapter Dim dt As DataTable Try dt = New DataTable cmd.Connection = _SQLConnection cmd.CommandType = CommandType.StoredProcedure cmd.CommandText = "nw_spSelectOrders" cmd.Transaction = _SQLTransaction If Not orderID.Equals(0) Then cmd.Parameters.Add(New SqlParameter("@orderID", SqlDbType.Int)) cmd.Parameters("@orderID").Direction = ParameterDirection.Input cmd.Parameters("@orderID").Value = orderID End If da.SelectCommand = cmd da.Fill(dt) If Not dt.Rows.Count > 0 Then Throw New Exception("no record") Else Return dt End If Catch ex As Exception Throw New Exception(ex.Message) Finally cmd.Dispose() da.Dispose() End Try End Function
SP for the function above: 0 - returns all dataSET ANSI_NULLS ON SET QUOTED_IDENTIFIER ON GO alter PROCEDURE nw_spSelectOrders ( @orderID int = 0 ) as begin Select o.orderID, od.quantity, od.unitprice, od.unitprice from orders as o left outer join [order details] as od on o.orderid = od.orderid where case when @orderID = 0 then 'selected' else case when o.orderID = @orderID then 'selected' else 'not selected' end end= 'selected' end
Whats wrong with passing 0? when I explicitly place orderID number I get result but passing 0 nada.. Please advice Thanks Guys -- modified at 20:49 Tuesday 11th September, 2007Uhh please advise what? The error is REALLY descriptive, and two people here have given you the answer. I advise you learn .NET or something, if you can't even figure out what a paremeterless constructor is.
-
Uhh please advise what? The error is REALLY descriptive, and two people here have given you the answer. I advise you learn .NET or something, if you can't even figure out what a paremeterless constructor is.
I don't mean to be harsh all of us do start from baby step, those two people has given helpful suggestions and you.. you simply throw snow ball and say I advise you learn .NET or something ... or something?? WAD! Big help anyways