Quiero saber si se puede imprimir los datos de un list<> en una table de html o si es necesario imprimirlos en un gridview
namespace tts
{
public class tabla_conexion
{
public DataTable connect()
{
string myConnectionString = @"C:\\Users\\gutiece\\Desktop\\database\\" + "Database1.accdb";
DataTable SBTable = new DataTable();
OleDbConnection connection = new OleDbConnection();
OleDbCommand command = new OleDbCommand();
OleDbDataAdapter adapter = new OleDbDataAdapter();
DataSet dataset = new DataSet();
try
{
connection.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0; Data source= " + myConnectionString;
bool ok = System.IO.File.Exists(myConnectionString);
String qry = "SELECT * FROM information_tool_gen";
command.Connection = connection;
command.CommandText = qry;
adapter.SelectCommand = command;
command.Connection.Open();
OleDbDataReader reader = command.ExecuteReader();
List<tabla> Resultado = new List<tabla>();
while (reader.Read())
{
Resultado.Add(new tabla(
int.Parse(reader["id_global"].ToString()),
int.Parse(reader["torque"].ToString()),
int.Parse(reader["tol"].ToString()),
reader["um"].ToString(),
reader["module"].ToString(),
reader["batteries"].ToString(),
reader["torquemeter"].ToString(),
int.Parse(reader["frequency"].ToString()),
DateTime.Parse(reader["maint_date"].ToString()),
int.Parse(reader["status_id"].ToString()),
DateTime.Parse(reader["reg_date"].ToString())
));
}
if (!reader.IsClosed)
{
reader.Close();
}
return SBTable;
}
catch (Exception)
{
}
return SBTable;
}
}
}
Tengo una clase donde hago el get y el set de los datos
namespace tts
{
public class tabla
{
public int ID_GLOBAL { get; set; }
public int TORQUE { get; set; }
public int TOL { get; set; }
public String UM { get; set; }
public String MODULE { get; set; }
public String BATTERIES { get; set; }
public String TORQUEMETER { get; set; }
public int FREQUENCY { get; set; }
public DateTime MAINT_DATE { get; set; }
public int STATUS_ID { get; set; }
public DateTime REG_DATE { get; set; }
public tabla(
int id_global,
int torque,
int tol,
String um,
String module,
String batteries,
String torquemeter,
int frequency,
DateTime maint_date,
int status_id,
DateTime reg_date
)
{
this.ID_GLOBAL = id_global;
this.TORQUE = torque;
this.TOL = tol;
this.UM = um;
this.MODULE = module;
this.BATTERIES = batteries;
this.TORQUEMETER = torquemeter;
this.FREQUENCY = frequency;
this.MAINT_DATE = maint_date;
this.STATUS_ID = status_id;
this.REG_DATE = reg_date;
}
private tabla() { }
}
}
sí
, se pueden imprimir en pantalla tanto por HTML como porGridView
, la respuesta dependerá de cuál deseas usar.