0

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.

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

4 Comments

well i can probably do it in plain html and asp.net web forms. But I thought of using the MVC and see how much difference does it make. What I am trying to achieve is based on the columns in the configuration file, I would like to generate the Labels in the View dynamically rather than strongly typed.
You're not understanding MVC..... MVC basically HTML with server tags <%= Model.Data1 %> to fill in the server generated data. But its basically structured around HTML. Webforms on the other hand generates HTML from server controls - MVC is very different.
thanks for your example, that made me understand much better.
No probs.... I'd recommend using MVC 3 at least though... It introduced a much simpler server view language called Razor which has pretty much become the standard. Here's a good cheat sheet to show the syntax differences haacked.com/archive/2011/01/06/…
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.