Database table dynamic (commidities are dynamic)
Id Month Commodity Amount
----------------------------
1 May wheat 100
2 May rice 200
3 June wheat 400
4 July maize 100
I can show it as it is on frontend easily but requirement is different
I want to display data with gridview in below format:
Month wheat rice maize
--------------------------------
May 100 200
June 400
July 100
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
getdata();
}
}
public void getdata()
{
using (GridFormatEntities context = new GridFormatEntities())
{
var result = (from r in context.tbl_Commodity
select new
{
Id=r.Id,
Month = r.Month,
Commodity = r.Commodity,
Amount = r.Amount
}).ToList();
grdData.DataSource = result;
grdData.DataBind();
}
}