简体   繁体   English

使用linq将一列动态添加到网格视图中

[英]Adding a column dynamically in to a grid view using linq

I have a grid view to which I bind data in to the grid view using a linq query. 我有一个网格视图,我使用linq查询将数据绑定到该网格视图。 I need to add a separate column to that grid view. 我需要在该网格视图中添加单独的列。 How can I add it? 如何添加?

I used the query shown below: 我使用了如下所示的查询:

DataTable dt = Common.dc.TblIssueDetails.Where(id => id.AssetId == 
LeAsset.EditValue.getInteger()).Select(id => new
    {
        Select=false,
        id.TblStoreStock.TblStock.TblItem.ItemName,
        id.TblIssueMaster.IssueDate,
        Quantity=0
    }).getDataTable();

Add another one property to your anonymous class: 将另一个属性添加到您的匿名类中:

DataTable dt = Common.dc.TblIssueDetails.Where(id => id.AssetId == 
LeAsset.EditValue.getInteger()).Select(id => new
         {
           Select=false,
           id.TblStoreStock.TblStock.TblItem.ItemName,
           id.TblIssueMaster.IssueDate,
           Quantity=0,
           SomeSeparateColumnName = someData // someData is data that you want to write to separate column.
          }).getDataTable();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM