I am getting this error
Sum is not supported for type "System.Object"
For testing purposes i am using one table only.
The table Design is
ProductID autonumber
ID int
ProductName Varchar(100)
Price Varchar(150)
Then i also added DataType=DataType=System.Decimal then i get an error
A value of type 'String' cannot be converted to type 'Decimal?'
This is my ASPX code
<
asp:Content
ID
=
"Content2"
ContentPlaceHolderID
=
"contentplaceholder1"
runat
=
"server"
>
<
telerik:RadScriptManager
runat
=
"server"
ID
=
"RadScriptManager1"
/>
<
telerik:RadSkinManager
ID
=
"QsfSkinManager"
runat
=
"server"
ShowChooser
=
"true"
/>
<
telerik:RadFormDecorator
ID
=
"QsfFromDecorator"
runat
=
"server"
DecoratedControls
=
"All"
EnableRoundedCorners
=
"false"
/>
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"RadGrid1"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadGrid1"
></
telerik:AjaxUpdatedControl
>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>
<
telerik:RadGrid
ID
=
"RadGrid1"
Width
=
"100%"
AllowSorting
=
"True"
ShowFooter
=
"True"
PageSize
=
"15"
AllowPaging
=
"True"
AllowMultiRowSelection
=
"True"
ShowChooser
=
"true"
runat
=
"server"
GridLines
=
"None"
AutoGenerateColumns
=
"False"
CellSpacing
=
"0"
DataSourceID
=
"ObjectDataSource1"
>
<
MasterTableView
Width
=
"100%"
Summary
=
"RadGrid table"
RetrieveAllDataFields
=
"false"
DataSourceID
=
"ObjectDataSource1"
>
<
CommandItemSettings
ExportToPdfText
=
"Export to PDF"
></
CommandItemSettings
>
<
RowIndicatorColumn
Visible
=
"True"
FilterControlAltText
=
"Filter RowIndicator column"
>
</
RowIndicatorColumn
>
<
ExpandCollapseColumn
Visible
=
"True"
FilterControlAltText
=
"Filter ExpandColumn column"
>
</
ExpandCollapseColumn
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"Productid"
HeaderText
=
"Productid"
DataType
=
"System.Int32"
SortExpression
=
"Productid"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"id"
HeaderText
=
"id"
DataType
=
"System.Int32"
FilterControlAltText
=
"Filter id column"
SortExpression
=
"id"
UniqueName
=
"id"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"ProductName"
HeaderText
=
"ProductName"
FilterControlAltText
=
"Filter ProductName column"
SortExpression
=
"ProductName"
UniqueName
=
"ProductName"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Price"
HeaderText
=
"Price"
SortExpression
=
"Price"
Aggregate
=
"Sum"
FooterText
=
"Total price: "
>
</
telerik:GridBoundColumn
>
</
Columns
>
<
EditFormSettings
>
<
EditColumn
FilterControlAltText
=
"Filter EditCommandColumn column"
>
</
EditColumn
>
</
EditFormSettings
>
</
MasterTableView
>
<
PagerStyle
Mode
=
"NextPrevAndNumeric"
></
PagerStyle
>
<
FilterMenu
EnableImageSprites
=
"False"
>
</
FilterMenu
>
</
telerik:RadGrid
>
<
asp:ObjectDataSource
ID
=
"ObjectDataSource1"
runat
=
"server"
SelectMethod
=
"GetListProduct"
TypeName
=
"Business.ProductManager"
></
asp:ObjectDataSource
>
</
asp:Content
>
/////////////////////////////////////////////////////////////////////////
public static ProductList GetListProduct()
{
ProductList tempList = null;
string sql = "SELECT * from Product";
//using (SqlConnection myConnection = new SqlConnection(AppConfig.ConnectionString))
using (SqlConnection myConnection = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["NLayer"].ConnectionString))
{
using (SqlCommand myCommand = new SqlCommand(sql, myConnection))
{
myConnection.Open();
using (SqlDataReader myReader = myCommand.ExecuteReader())
{
if (myReader.HasRows)
{
tempList = new ProductList();
while (myReader.Read())
{
tempList.Add(FillDataRecordProduct(myReader));
}
}
myReader.Close();
}
}
return tempList;
}
}
private static Product FillDataRecordProduct(IDataRecord myDataRecord)
{
Product myUserTracking = new Product();
myUserTracking.Productid = myDataRecord.GetInt32(myDataRecord.GetOrdinal("Productid"));
myUserTracking.id = myDataRecord.GetInt32(myDataRecord.GetOrdinal("id"));
myUserTracking.ProductName = myDataRecord.GetString(myDataRecord.GetOrdinal("ProductName"));
myUserTracking.Price = myDataRecord.GetString(myDataRecord.GetOrdinal("Price"));
return myUserTracking;
}