How to use the list when it does not know the object that will be returned?

1

I have an Oracle database and need a popular gridView . I'm doing with var , because I do not know the type that will be returned. Can you make a list in var , example list<var> , and then play on grid ?

gridview1.datasource = lista var
grindview1.dataBird():

foreach (var nota in info)
{
    var prod = bd.PRODUTOes.Where(p => p.NOTA_FISCAL.Any(n => n.ID == nota.ID));
}
    
asked by anonymous 16.11.2017 / 19:56

1 answer

1

I was able to resolve:

DataTable dt = new DataTable();

dt.Columns.Add("nome");
dt.Columns.Add("VALOR_UNIT");

foreach(var nota in info)
{
   var prod = bd.PRODUTOes.Where(p => p.NOTA_FISCAL.Any(n => n.ID == nota.ID)).ToList();


   foreach(PRODUTO detalheProduto in prod)
   {
      dt.Rows.Add(detalheProduto.NOME, detalheProduto.VALOR_UNIT.ToString());
   }

}

GridView1.DataSource = dt;
GridView1.DataBind(); 
    
17.11.2017 / 17:10