Click here to Skip to main content
15,913,669 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Dear friends i am creating a MVC application in that i need to display instruments by differentiate parent and child. My sql table looks like

ID Name ParentId
-------------------
1 --Musical Instrument -- 0

2 --Classical -- 1

3 --Guitar -- 2

4 --Piano -- 2

5 --Western -- 1

6 --Drums -- 5

7 --Trumpet -- 5

8 --Trumpet A -- 7

9 --Trumpet B -- 7

i need to display this in table view instead of Tree view. anyone please help me.
Posted
Updated 16-Apr-14 3:13am
v4

Please try is as below.

Note:This is just a sample.May be have syntax errors. Plz Adjust it according to your app.

<table id="shoppingCart">
                        <tr>
                            <th>
                                Product Name
                            </th>
                            <th style="text-align: center;">
                                Price ($)
                            </th>
                            <th style="text-align: center;">
                                Discount ($)
                            </th>
                       </tr>

                        @foreach (var item in Model.YourList)
                           {
                        <tr id="row-@item.Id">
                            <td>
                                @item.ProductName
                            </td>
                            <td>
                                @item.RetailerPrice
                            </td>
                            <td>
                                @item.Discount
                            </td>
                           
                        </tr>
                         }
                    </table>


HTML Table Example
 
Share this answer
 
You can find solution here:
http://www.dotnetcode2u.com/2015/12/binding-datatable-from-database-in-mvc4.html
 
Share this answer
 

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