Mihai Labo
Mihai Labo

Reputation: 1082

Placing a Dictionary inside Viewbag

I'm trying to access a Dictionary in my View . But the following syntax :

@{
    var indexList = Viewbag.IndexList as Dictionary<int,long>;
}

doesnt work : The name 'Viewbag' does not exist in the current context

P.S. :Tried placing '@' before Viewbag ,still doesn't work.

Can someone help ? Thanks in advance

Upvotes: 0

Views: 6241

Answers (2)

Alexandre N.
Alexandre N.

Reputation: 2802

Try this way:

var indexList = this.ViewBag.IndexList as Dictionary<int,long>;

Upvotes: 0

Paul
Paul

Reputation: 5576

is it not ViewBag?

var indexList = ViewBag.IndexList as Dictionary<int,long>;

Upvotes: 5

Related Questions