[英]Using a Details View, is there any way during Page_Load (or anywhere) to only display non-null fields?
I've been receiving help with a program I've been working on from you guys (and I really appreciate it as I'm fairly new to ASP.NET
), but now I'm stuck again. 我一直在接受你们正在开发的程序的帮助(由于我对
ASP.NET
很陌生,所以我非常感谢它),但是现在我又陷入了困境。
I've got my List<Products>
that contains one Product object with 17 properties(representing the fields). 我的
List<Products>
包含一个具有17个属性的Product对象(代表字段)。 Some of these properties may be null(well actually, I already coded it so that if the field in the database was null, convert the properties to either "" or -1). 其中一些属性可能为null(实际上,我已经对其进行了编码,因此,如果数据库中的字段为null,请将属性转换为“”或-1)。
Is there any way to only create fields for the properties that aren't null
in my Details View using ASP.NET/C#
or do I have to use Javascript
or something else? 有什么方法可以使用
ASP.NET/C#
只为详细信息视图中不为null
的属性创建字段,还是必须使用Javascript
或其他方法? I can provide what I have thus far if necessary. 如果需要,我可以提供到目前为止的内容。
In Your product class make all properties Nullable 在您的产品类别中,使所有属性为空
like int? productId
喜欢
int? productId
int? productId
so it will not bind when it's value is null 所以当它的值为null时它不会绑定
http://msdn.microsoft.com/en-us/library/2cf62fcy%28v=vs.80%29.aspx http://msdn.microsoft.com/zh-CN/library/2cf62fcy%28v=vs.80%29.aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.