Hello Telerik team
I'm using , use DataTable to load data grid.
This is my Index code
@model SystemDataDataTable
@HtmlKendo)Grid<
dynamic
>()
Name"Grid")
Columnscolumns =>
{
Bound"ID");
Bound"Name");
Bound"UnitPrice")Width100);
Bound"UnitsInStock")Width100);
Command => Edit); Destroy);)Width160);
})
toolbar => toolbarCreate))
)
)
ed=>ModeGridEditModePopUp))
Filterable)
=>
Ajax)
Modelmodel =>
{
id = ModelPrimaryKey0]ColumnName;
Idid);
(SystemDataDataColumn column in ModelColumns)
{
field = modelFieldcolumnColumnName, columnDataType);
(columnColumnName == id)
{
Editablefalse);
}
}
})
//Aggregatesa =>
//{
// //Add"UnitPrice", typeofdecimal?))Sum);
// //Add"UnitsInStock", short?))Average)Max);
// Add"Total (Price*Quantity)", short?));
//})
Readread => readAction"GetProductsList", "Home"))
Destroydestroy => destroyAction"DestroyProduct", "Home"))
)
)
This is my HomeController
;
SystemCollectionsGeneric;
SystemLinq;
SystemWeb;
SystemWebMvc;
KendoMvcUI;
KendoMvcExtensions;
SystemData;
SystemDataSqlClient;
SystemConfiguration;
GridBindingToDataTableControllers
{
class
HomeController Controller
{
string
str_connection = ConnectionStrings
"KloonDB"
]ConnectionString;
ActionResult Index)
{
DataTable dt_products = GetProductsList);
Viewdt_products);
}
ActionResult About)
{
View);
}
ActionResult GetProductsList[DataSourceRequest] DataSourceRequest request)
{
DataTable products = GetProductsList);
(requestAggregatesAny))
{
AggregatesEach =>
{
AggregatesEacha =>
{
= productsColumnsMember]DataType;
});
});
}
JsonproductsToDataSourceResultrequest));
}
ActionResult DestroyProduct[DataSourceRequest] DataSourceRequest request,
)
{
);
//Delete Product at server side
DataTable dt_products = GetProductsList);
// grid
Jsondt_productsToDataSourceResultrequest));
}
DataTable GetProductsList)
{
str_SQLSelectcommand =
"SELECT IDNamePriceQuantityStatusIdColor from Tbl_Products"
;
( =
new
SqlDataAdapterstr_SQLSelectcommand, str_connection))
{
=
new
DataTable);
Fill);
FillSchema, SchemaTypeMapped);
;
}
}
void
DestroyProductInDatabase
)
{
(SqlCommand command =
new
SqlCommand))
{
Connection =
new
SqlConnectionstr_connection);
CommandType = CommandTypeText;
//I don't want to use
CommandText =
"Delete from [Tbl_Products] where [ProductID] = @ProductID"
;
command.Parameters.Add(
new
SqlParameter(
"@ProductID"
, SqlDbType.Int)).Value = iProductID;
ExecuteNonQuery);
}
}
}
}
I set breakpoint in VS 2013 and when I click delete button in . It won't jump to breakpoint in VS 2013. When I set breakpoint , it works fine.
Can someone help me why I can't delete data in .
Thank you.