Click here to Skip to main content
16,014,589 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I successfully stored one value in view bag in controller.like below
@viewbag.pid=20

i want to display this 20 in my view for that i write below code
@view.pid

But my problem is i am not able to display in my page please help me out.
Posted
Updated 28-Aug-13 23:10pm
v2

Try This..

@ViewBag.pid
 
Share this answer
 
In your controller write

C#
ViewBag.Message = "Welcome to ASP.NET MVC!";


To access it in respective view use razor syntax as below

@ViewBag.Message
Hope this will help you.
 
Share this answer
 
Comments
sarath from cst 29-Aug-13 5:31am    
Ya i tried but not getting
Jitendra Sabat 29-Aug-13 5:37am    
Can you put your controller code as well as your view code for reference???
sarath from cst 29-Aug-13 5:52am    
using WebShopDesigns.EShop.UI.Webpages.Mvc4.Models
i am added reference like above in my controller
Jitendra Sabat 29-Aug-13 5:55am    
using System.Web.Mvc;
Make sure that your controller class is inherited from "Controller".It should work out.
sarath from cst 29-Aug-13 6:51am    
Ya i mentioned there....
Try ViewBag.pid instead of @View.pid.
 
Share this answer
 
Comments
sarath from cst 29-Aug-13 5:30am    
Ya i tried but not getting
Try ViewBag.pid instead of @View.pid.
 
Share this answer
 
Comments
sarath from cst 29-Aug-13 5:30am    
Ya i tried that one also but its not displaying

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