Class1.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
public class Listas
{
public class Columnas
{
public string Col1 { get; set; }
public string Col2 { get; set; }
public string Col3 { get; set; }
}
public static List<Columnas> MiMetodo()
{
List<Columnas> lista = new List<Columnas>();
lista.Add(new Columnas
{
Col1="1racosa",
Col2="2dacosa",
Col3="3racosa"
});
return lista;
}
}
default.aspx.cs
GridView1.DataSource = Listas.MiMetodo();
GridView1.DataBind();
default.aspx
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:BoundField DataField="Col1" HeaderText="Col1" />
<asp:BoundField DataField="Col2" HeaderText="Col2" />
<asp:BoundField DataField="Col3" HeaderText="Col3" />
</Columns>
</asp:GridView>
No hay comentarios:
Publicar un comentario