当前位置: 首页 > 编程语言 > C#

WebGridisprintinganemptytableShare

时间:2023-04-11 00:38:38 C#

WebGridisprintinganemptytable谁能看出为什么这个简单的测试站点会打印一个空表(在tehhtml中,创建了一个用2行(tr)编写的表,但是没有生成的单元格(td))。或者如何以最佳方式调试它DebugController.cs...usingSystem;使用System.Collections.Generic;使用System.Web;使用System.Web.Mvc;namespacemyproject.Controllers{publicclasstype1{publicStringipAddress;公共字符串connectionId;}publicActionResultDebug2(stringarg1){Listobj1=newList();obj1.Add(newtype1{ipAddress="192.168.1.1",connectionId="123"});obj1.Add(newtype1{ipAddress="192.168.1.2",connectionId="345"});ViewBag.obj1=obj1;返回视图();}}}和Debug2.cshtml......@{布局=null;}@{vargrid=newWebGrid(ViewBag.obj1);@grid.GetHtml()我可能会尝试更强的打字。此外,IIRC您必须在模型上使用属性而不是字段,以便WebGrid助手可以选择它们:publicclassType1{publicstringIPAddress{get;放;}publicstringConnectionId{得到;放;}}在你的行动中:publicActionResultDebug2(stringarg1){varmodel=newList();model.Add(newType1{IPAddress="192.168.1.1",ConnectionId="123"});model.Add(newType1{IPAddress="192.168.1.2",ConnectionId="345"});返回视图(模型);最后,在你的强类型视图中:以上是C#学习教程:WebGrid正在打印一张空表的所有内容,如果你对C#学习教程有帮助,需要了解更多,希望大家多多关注——@modelIList@{布局=null;}@{vargrid=newWebGrid(Model);}@grid.GetHtml()本文来自网络收藏,不代表立场,如涉及侵权,请点击右侧联系管理员删除。如需转载请注明出处:

最新推荐
猜你喜欢