ASP.NET - how to bind gridivew with linq query

Asked By bhanupratap singh on 13-Jul-12 04:41 AM
Hi 
I want to bind gridview summing column value from table using linq. but it gives error of Enumberal
var amount = (from p in dc.CONSIGNMENTs
                    where p.CODE_NAME == ListBoxFrom.SelectedValue
                    select p.TOTAL).Sum();


      Response.Write(amount);
      GrvEnquiry.DataSource = amount.ToString();
      GrvEnquiry.DataBind();
Asked By bhanupratap singh on 13-Jul-12 07:35 AM
thanks

then how to bind it
Jitendra Faye replied to bhanupratap singh on 13-Jul-12 08:42 AM
Try this code-

var amount = (from p in dc.CONSIGNMENTs
                    where p.CODE_NAME == ListBoxFrom.SelectedValue
                    select p.TOTAL).Sum();



      GrvEnquiry.DataSource = amount.ToList(); 
    GrvEnquiry.DataBind();