我正在GridView中显示某些记录的详细信息。 有时记录有详细信息,有时却没有。
在RowDataBound事件上,我需要设置行的可见性。 如果行中有数据,请显示它,否则不显示它。这就是我正在做的方法:
template<template<typename...> typename TT, typename... Ts>
struct two { /* */ };
template<typename...>
struct Void;
template<typename T>
struct two<Void<>, T> { /* Use T like in one */ };
// or derive from one<T>
没有详细信息可显示
protected void gvBins_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { string bin = DataBinder.Eval(e.Row.DataItem, "BinNumber").ToString(); if(bin.length == 0) e.Row.Visible = false; } }
我该如何解决?
这是该字段的ItemTemplate:
System.NullReferenceException: 'Object reference not set to an
instance of an object. System.Web.UI.DataBinder.Eval(...) returned
null.'
对于该特定记录,没有详细信息,因此我想使这些行不可见。
处理此问题的最佳方法是什么?