0

我有以下 linq to sql 查询,我绑定到详细信息视图

            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 为空。

如果它们为空,我不想向用户显示这些属性。

我该怎么做???任何的想法???

4

1 回答 1

0

好的,我自己明白了:这是我想出的

DV_ChallanDetails.AutoGenerateRows = false; 
BoundField bow = new BoundField();
bow.DataField = "bowzer_no"; 
bow.HeaderText = "Bowzer No"; 
DV_ChallanDetails.Fields.Add(bow); 

我对每个字段都这样做,如果任何字段为空,只需将其可见属性设置为 false

谢谢

于 2012-06-04T04:26:40.223 回答