I am a beginner. I am finding it very difficult to understand one concept here.
I have been told that I should not use DataTable in UI level.
Please help me understand the concept.
Solution:
MyApp.Data
MyApp.Logic
MyApp.Web
MyApp.Web references MyApp.Logic, and MyApp.Logic references MyApp.Data.
On my application, what I am trying to do is simply bind a gridview by the tablename, which is chosen from a dropdownlist. However, there are hundreds and more tables. The purpose here is just to display data to the user (with paging).
So a class "Get_Data" on project MyApp.Data has a function:
public static DataTable Get_DataTable_By_Name(string Table_Name)
{
//Check and santize the table name for possible SQL injection attack.
//SELECT FROM DATABASE TABLE.
return DataTable;
}
From MyApp.Logic, I am just passing the datatable from the MyApp.Data tier to MyApp.Web. And then the gridview is bound and everything is working here.
So what I am doing wrong here? Is it really bad to have datatable in UI level? Why is it a bad design?