Dynamically Create templates in mvc 4

2 posts, 0 answers
  1. sirisha
    sirisha avatar
    3 posts
    Member since:
    Oct 2013

    Posted 11 Nov 2013 Link to this post

    Hi team,

    I want create Dynamic templates.In the below link sample showing the static template.
    My requirement is  bind the dropdown list dynamically and based on change event bind another control .
    Could you please suggest how to crate this type of templates in MVC  and If you have any samples could you please send? 
  2. Petur Subev
    Petur Subev avatar
    1882 posts

    Posted 13 Nov 2013 Link to this post

    Hello Sirisha,

    Basically you can render different template based on conditional logic like explained here:


    Howeve I assume that for your case you want to create the DropDownList with JavaScript and bind it to different dataSource based on the data for that particular row. 

    To actually achieve this I would suggest you to put a single input element in the template (with some class) and use the dataBound event of the Grid to initialize the DropDownList. To get a reference to the model while initializing the different DropDownList you can use the dataItem method of the Grid.

    To get the idea please take a detail look at the following example:


    It uses absolutely the same approach like the one that I explained above, however it uses a field which actually holds the whole collection (in your case you might just need an id to configure the remote transport of your DropDownList) to initialize the Chart.

    I hope this gives you the idea and helps you achieve your goal.

    Kind Regards,
    Petur Subev
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top