Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
Hello everyone,

I am developing a MVC4 project. I did lots of things. This part is the end of project.

Basically, system has teachers and an admin. Teachers select a day and free time(s)

Admin wants to see all the free times in a table. I create a table as Calendar in DB. I keep TeacherID, DayID and Explanation( that field keeps the free times as string.)

In view side a took the list of calendar items as model.

I want to create a table


@foreach(day in ViewBag.Days)
Day.Name




HTML
@model IEnumerable<KampusOzelDersProjesi.Models.Takvim>
<div class="container-fluid">
    <div class="row-fluid">
        <!--/span-->
        <div class="span9" id="content">
            <!-- morris stacked chart -->
            <div class="row-fluid">
                <!-- block -->
                <div class="block">
                    <div class="navbar navbar-inner block-header">
                        <div class="muted pull-left">
                            Takvim</div>
                    </div>
                    <div class="block-content collapse in">
                        <div class="span12">
                            <table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered"
                                id="example">
                                <thead>
                                    <tr>
                                        <th>
                                            <center>
                                                #
                                            </center>
                                        </th>

                                        @foreach (var gunler in ViewBag.Gunler)
                                        {
                                            <th>
                                                <center>
                                                    @gunler.Adi
                                                </center>
                                            </th>
                                        }
                                    </tr>
                                </thead>
                                <tbody>
                                    @foreach (var takvim in Model)
                                    {
                                        <tr class="odd gradeX">
                                            <td>
                                                <center>
                                                    @takvim.Ogretmen.Adi
                                                </center>
                                            </td>
                                            <td>
                                                <center>
                                                    
                                                </center>
                                            </td>
                                            <td>
                                                <center>
                                                    
                                                </center>
                                            </td>
                                            <td>
                                                <center>
                                                    
                                                </center>
                                            </td>
                                            <td>
                                                <center>
                                                    
                                                </center>
                                            </td>
                                            <td>
                                                <center>
                                                    
                                                </center>
                                            </td>
                                            <td>
                                                <center>
                                                    
                                                </center>
                                            </td>
                                            <td>
                                                <center>
                                                    
                                                </center>
                                            </td>
                                        </tr>
                                           
                                    }
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <!-- /block -->
                </div>
                <!-- /block -->
            </div>
        </div>
    </div>
</div>

Till this part, everything is Ok.

In the head of table, there are days(the easiest part)

In the table body part, the first row should be teacher names and surnames. If I use the Model in foreach, as expected there are double teacher names in the first column; such as FofRoot, FoxRoot, FoxRoot. The other problem, How can I get the items of teacher 'X' at Day 'Y' ?

I need help on algorithm.

Project is being developed on Asp.Net MVC4.
Posted
Updated 5-Nov-13 4:03am
v2
Comments
Sergey Alexandrovich Kryukov 5-Nov-13 9:45am    
What do you mean by "table" above?
—SA
FoxRoot 5-Nov-13 9:50am    
I have a table 'Calendar' in DB. It keeps the teacherID, DayID and Content.

For example I am a teacher and my ID is 1 and Today's Id 2 Content is Hello. My Id is again 1 tomorrow's id is 3 and Content is 'MVC Rocks!'
You are also a teacher and your ID is 2 and Today's Id 2 Contet is Hi.

so, calendar table should carry the followings in DB.

1 1 2 'Hello'
2 1 3 'MVC ROCKS'
3 2 2 'Hi'

If Until here is Ok I want to continue, what I wanted to do.
Sergey Alexandrovich Kryukov 5-Nov-13 14:57pm    
Okay, a table in DB. But then, you cannot talk about "head of a table". What is that?
—SA
FoxRoot 6-Nov-13 10:42am    
Did you check the image? http://o1311.hizliresim.com/1h/5/u7ugl.jpg
Sergey Alexandrovich Kryukov 6-Nov-13 11:00am    
Yes. UI tables have headers, DB tables do not. Not a correct question...
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900