Click here to Skip to main content
16,015,218 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all experts,
I have problem to assign value from viewbag in controller to array in javascript.
This is source code in controller.
C#
List<general> s = new List<general>();
foreach (DataRow r in supplier.Rows)
{
  s.Add(new general
  {
    col1=r[quot;amcode"].ToString(),
    col2=r[quot;amname"].ToString(),
    col4=Convert.ToDouble(r["foc"].ToString())
  });
}
ViewData["group"] = g;

So it means that my ViewData has the same row as datarow.

and in javascript:
I want to get all value from ViewData["group"] and assign that value from array in javascript.

Does anybody know how i can do it?

Thanks
Posted
Comments
vijay__p 17-May-13 1:14am    
what is g ?
vijay__p 17-May-13 1:15am    
To access complex type in javascript put JSON serialized string into ViewData/ViewBag and access it in javascript.

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