text: Q:
  
  not getting integer values stored in viewbag on view page
  
  i have list of integer values in my view bag
   List<int> ChkOptions = {1,2,3,4.......}
  
   for (int i = 0; i < ChkOptions.Count(); i++)
   {
    ViewBag.ChkOptions = ChkOptions.ElementAt(i);
    }  
  
  Now i want to take this viewbag value on my view page.
  this is what i am doing on my view page but it it throwing me error on dis line:
   var chk = (List<int>)ViewBag.ChkOptions;
  
  Cannot convert type 'int' to System.Collections.Generic.List
  can any one tell me how do i take all this integer values from viewbag on my view in var variable??
  
  A:
  
  This will work :-
  Controller :-  
   List<int> ChkOptions = {1,2,3,4.......}
  
   ViewBag.ChkOptions = ChkOptions;
  
  View :-
  var chk=ViewBag.ChkOptions as List<int>;
  
  Or use foreach to traverse your List as :
  @foreach(var item in ViewBag.ChkOptions as List<int>)
  {...}
  
  