将RadGridView与存储过程的结果绑定在EntityFramework中

时间:2013-12-15 11:12:14

标签: c# winforms linq entity-framework radgridview

我已将存储过程的结果(在Entity Framework中)存储在IList中,然后使用此IList绑定我的网格。当此结果为null时,网格没有任何列,但我需要在网格中显示这些列。有没有办法解决这个问题?

这是我的代码:

IList list = new ArrayList();

try
{
    var context = new SabzNegar01Entities1();

    list = (from p in context.tbl_ReturnSalesFactor_D
            let add = (p.MainNum * p.Fee)
            let pureAdd = ((p.MainNum * p.Fee) - (p.MainNum * p.Discount)) + ((p.Tax + p.Charges) * p.MainNum)
            let taxChange = (p.Tax + p.Charges) * p.MainNum
            let discount = p.Discount * p.MainNum
            where p.DocNo == inDocNo
            select new { p.Row, p.StockCode,  p.tbl_Stock.PDescription, p.Fee, p.MainNum, add, taxChange, discount, pureAdd }).ToList();
}
catch (Exception ex)
{
    PMessageBox.Show(ex.Message, "Error in Reading  ReturnSalesFactor_Details Data");
}

和绑定:

radGridView_Product.DataSource = list ;

0 个答案:

没有答案