0

Is it possible to display the information of two tables that have a relationship inside a grid view?

For example, the name student and profile of table 1

And their Absent student from Table 2

And we'll display the information of both together at the same time in a grid view. I'm glad to be a beginner. https://i.stack.imgur.com/IFptY.jpg

gingerbreadboy
  • 7,386
  • 5
  • 36
  • 62

2 Answers2

0

You could try something like:

SELECT * FROM Tbl_Gheybat, InfoStudent WHERE Tbl_Gheybat.IdForenKey = InfoStudent.Id;
0

You can build up a new ViewModelto be displayed at the gridview

For example: let say you have a two classes in relation with each other Student and AbsentStudent in your code you will create a new ViewModel class and fill in the data you want to display in the grid

Mohamed Salah
  • 959
  • 10
  • 40
  • There is no other solution؟؟؟ – Mohammad.hadinezhad Jun 14 '19 at 14:17
  • I think this is the easiest solution, or you can add a new property to the main domain with the value you want and map it in your query. then display it normally but make sure its not database mapped to avoid conflict with database operations. – Mohamed Salah Jun 14 '19 at 14:25
  • one question. then i can insert or update on the viewMode – Mohammad.hadinezhad Jun 14 '19 at 14:34
  • what do you mean by you can insert or update on the viewmodel? View Model is a model class that can hold only those properties that is required for a view. It can also contains properties from more than one entities (tables) of the database. As the name suggests, this model is created specific to the View requirements. as per the following 'https://stackoverflow.com/questions/11064316/what-is-viewmodel-in-mvc' – Mohamed Salah Jun 14 '19 at 14:37
  • if this was helpful answer for you please mark it as an answer – Mohamed Salah Jun 17 '19 at 12:31