I want to write column name dynamically in a collection. My collection is in ViewBag and in ViewData.
I am trying
@{foreach (var item in ViewData["example"] as List<exampleList> )
{
<h1>@item["column" + column_id]</h1>
and item[ in above code gives error.
and also I have tried
@{foreach (var item in ViewBag.example )
{
<h1>@item.(column + column_id)</h1>
Also not working.
I just want to write the column name by myself in h1. I dont want intellisense choose for me. There are language suffixes at the end of everycolumn in my table.
such as name_fr, name_de, name_en
I just want to bring culture code there. For example: name + culture code.
If I type @item.name_fr It works. But I want to put there "fr" dynamically.
exampleList is just a class created by Ado.net entity data model. There is no problem with the class. It is a simple class. It doesn't have any data annotations.
The error is "Cannot apply indexing with [] to an expression of type"
What can be my mistake? What I am trying to get is possible or not?