我有以下linq to sql查询,我绑定到detailsview
var ShippingChallan = (from sc in db.ShippingChallanViewSeconds
where sc.challan_id == Convert.ToDecimal(txtChallanNo.Text) && sc.SecondWeight != null && sc.Type == "LBO"
select new {
sc.challan_id,
sc.bowzer_no,
sc.FirstWeight,
sc.SecondWeight,
sc.netWeight,
sc.Product_Name,
sc.FLD,
sc.Customer_Name,
sc.dip1,
sc.Cmpt_Capacity1,
sc.dip2,
sc.Cmpt_Capacity2,
sc.dip3,
sc.Cmpt_Capacity3,
sc.dip4,
sc.Cmpt_Capacity4,
sc.dip5,
sc.Cmpt_Capacity5
}).FirstOrDefault();
在99%的行中,sc.dip4和sc.dip5为空。
如果用户为null,我不想向用户显示这些属性。
我该怎么办?任何想法???
答案 0 :(得分:0)
好吧,我自己得到了:这就是我想出来的
DV_ChallanDetails.AutoGenerateRows = false;
BoundField bow = new BoundField();
bow.DataField = "bowzer_no";
bow.HeaderText = "Bowzer No";
DV_ChallanDetails.Fields.Add(bow);
我为每个领域做,并且如果任何领域是空的并且只是将其可见属性设置为假
感谢