Reputation: 1172
I am kind of new to the world of ASP.NET (especially MVC), I am trying to build up a page based on the configuration below:
<headInput>
<defaultColumns>
<column name="Shift" validation="" unit="" required="" />
<column name="Level" validation="" unit="" required="" />
<column name="Value" validation="" unit="" required="" />
<column name="Time" validation="" unit="" required="" />
</defaultColumns>
<additionalCols1>
<column name="Rate" validation="" unit="" required="" />
</additionalCols1>
<additionalCols2>
<column name="Online" validation="" unit="" required="" />
<column name="Type" validation="" unit="" required="" />
</additionalCols2>
</headInput>
I have been trying to understand on how I can use the above configuration to generate labels as columns and then generate the row with data in columns.
I tried looking at many examples but haven't been able to figure out if it is even possible or not. Any help would be appreciated.
Thanks.
Upvotes: 0
Views: 485
Reputation: 9312
Looks like you need to generate HTML based on the XML input. You can use XSLT to do that.
Your MVC model should provide the XML and the View should use the XSLT to convert it to the HTML
here are few links which might be helpful -
http://www.htmlgoodies.com/beyond/xml/converting-xml-to-html-using-xsl.html
https://web.archive.org/web/20210301191904/https://www.4guysfromrolla.com/webtech/081300-2.shtml
Upvotes: 0
Reputation: 26909
I'm not sure what you're trying to do or what schema you're using in the example above, but my feeling is that you should be using HTML tables for this:
http://www.w3schools.com/html/html_tables.asp
http://www.w3.org/TR/html4/struct/tables.html
Tables are defined in rows, not columns, first with the heading row ( then the data rows then the table data .
Also look at the colspan attribute and the rowspan attribute which I think you'll need for this - lets columns span more than one row and rows span more than one column.
Also if you're learning MVC why are you using a 2 year old version?? MVC3 was released over a year ago and MVC 4 is in beta with a go-live license. We're using MVC 4 to develop a web based stock trading application and its solid as a rock.
There's an example of building an HTML table using MVC at http://www.asp.net/mvc/tutorials/older-versions/models-(data)/displaying-a-table-of-database-data-cs (scroll to the bottom to see the MVC view) Its basically HTML with some server tags for pulling the data from the model. That's how MVC is - very different from webforms where you'd have server controls generating HTML for you.
Upvotes: 1