Click here to Skip to main content
15,920,508 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi friends,
I want to create only view part, where in I'm making dummy data as below

XML
@foreach (var item in new List<Object> {
                                           new { market = "UK", collectionGroupName="Collection Group 1",GTS="yes",processingCenter = "Processing Centre 1"},
                                           new { market = "UK", collectionGroupName="Collection Group 1",GTS="yes",processingCenter = "Processing Centre 1"},
                                           new { market = "UK", collectionGroupName="Collection Group 1",GTS="yes",processingCenter = "Processing Centre 1"},
                                           new { market = "UK", collectionGroupName="Collection Group 1",GTS="yes",processingCenter = "Processing Centre 1"},
                                       })
                                   {
                                       <tr>
                                           <td class="ProductListTable_TD">@item.market</td>
                                           <td class="ProductListTable_TD"></td>
                                           <td class="ProductListTable_TD"></td>
                                           <td class="ProductListTable_TD"></td>
                                           <td class="PadRig_AlignRgt">
                                               <input type="button" class="btnEdit" name="btnEdit" value="Edit" data-href="#content1" />
                                           </td>
                                       </tr>
                                   }


How can I access the market, GTS and other property from the item?

If I try to access as below it gives an error
@item.market

Any idea?

Thanks in advance
Posted
Comments
Maciej Los 14-Oct-14 7:20am    
What error?
dhage.prashant01 14-Oct-14 7:26am    
It cannot find market in the item
Maciej Los 14-Oct-14 7:36am    
Is this the exact message?
Have you tried to define class?
class SomeName
{
public string market
//... other properties

}

and then to create List<SomeName>?
dhage.prashant01 14-Oct-14 7:50am    
Actually I don't want to create model now.
I have to just create UI using MVC helper classes.

1 solution

This is not possible dear. Here the @item is just simply of type string not an object. You need to pass a script where you need to use Json.stringify.
You cannot access the @item.market like this.
If the values of the properties are static why use foreach and List<>??
If you get the values from Model i.e. Server side then use foreach.
Hope you get.
Please post back comments regarding queries if any.
Thanks
:)
 
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