views:

26

answers:

1

I want to create a listing view in which the record will be in this format(basically one record based on other, what approach i should follow) .

My table
Module1
Module1Feature
Module1Feaure2
Module1Feature3

Module2
Module2Feature
Module2Feature2
Module2Feature3

Basically Please Notice that the child records are based on the parent.

+1  A: 

Assuming you are using LinqToSQL as your backend, then you probably already have your foriegn key relationships setup (right?). Which means that you should have a table with your modules and a table for your moduleFeatures with a FK back to table modules.

In your controller, you return all of your modules as such

Function Index() as actionresult
      return(repository.getModules())
End Function

Then in your View, you can do something like this

For each module in model
    Html.Encode(module.moduleName)
    For each feature in module
         Html.Encode(feature.featureName)
    Next
Next
Tommy
No they are all in the same table named features , if something is module then ismodule is true for it otherwise false for features
mazhar kaunain baig
I would rethink the database schema as any type of grouping, ordering, etc. will be much more easy if you create a one to many relationship as opposed to storing in a single table. You will save yourself some heartache in the future.
Tommy