Gridview显示空行

时间:2013-11-25 17:46:53

标签: c# linq

我正在使用Linq-to-SQL,当我选择要在gridview中显示的记录时,我的gridview显示空记录。我可以看到这行,但它们是空的

public class showFacReq
{
            public string documentNumber;
            public string fixPaperNumber;
            public string letterDate;
            public string letterNumber;
            public string propertyFactoryCenteralId;
            public string requestId;
            public string year;
}

public List<showFacReq> ShowFactoryRequset()
{
    List<showFacReq> q = (from i in dbconnect.tblFactoryRequests.AsEnumerable()
                          select new showFacReq
                                         {
                                             documentNumber = i.documentNumber,
                                             fixPaperNumber = i.fixPaperNumber,
                                             letterDate =ConvertToPersianToShow(i.letterDate),
                                             letterNumber = i.letterNumber,
                                             propertyFactoryCenteralId = i.propertyFactoryCenteralId,
                                             requestId = i.requestId.ToString(),
                                             year = i.year
                                         }).ToList();
    return q;
}

2 个答案:

答案 0 :(得分:5)

将班级的所有字段都转换为属性。只有属性才会暴露。像这样:

public class showFacReq {
  public string documentNumber {get;set;}
  //do the same for others
  //....
}

答案 1 :(得分:0)

尝试在gridview中包含列,并将记录的每个属性绑定到每个列。像Record.documentNumber, Record.fixPaperNumber