开发者

How to display list of names present in viewdata in asp.net

I have a list of names in viewdata, but am not able to display it in view page

<body>

    <%= ViewData["names"].T开发者_开发百科oString() %>

Thanks


If it's a list of strings, you have to iterate through it like so (I've put a div there just to illustrate):

<% foreach (var name in (List<String>)ViewData["names"]) { %>
   <div><%= name %></div>
<% } %>

You also must make sure that ViewData["names"] is not null.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜