0
Today I recover information from a database and I list in a REPEATER, until then all blz. But I also need to take an image from the database and show on this REPEATER.
Follow below as I show the table.
So I want to put a column with the image.
Below code of class retrieving data from database:
public SqlDataReader ListarClientes()
{
String query_string = "select codcliente,razaosocial,cidade,imagem from cliente";
SqlConnection conexao = new SqlConnection();
conexao.ConnectionString = this.string_conexao;
conexao.Open();
SqlCommand comando = new SqlCommand();
comando.CommandText = query_string;
comando.Connection = conexao;
SqlDataReader dr = comando.ExecuteReader();
return dr;
}
Aspnet code
<h2>Lista de clientes</h2>
<form id="form1" runat="server">
<div class ="container"
<div class =" row col-md-6 col-md-offset-2 custyle">
</div>
</div>
<br />
<br />
<div class="container">
<div class="row col-md-6 col-md-offset-2 custyle">
<asp:Repeater ID="rptCliente" runat="server">
<HeaderTemplate>
<table class="table table-striped custab">
<a href="InsereCliente.aspx" class="btn btn-primary btn-xs pull-right"><b>+</b> Novo</a>
<tr >
<td>
<font ><b>Código</b></font>
</td>
<td>
<font ><b>Nome</b></font>
</td>
<td>
<font ><b>cidade</b></font>
</td>
<td align="center">
<font ><b>Ação</b></font></td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr >
<td>
<%# DataBinder.Eval(Container.DataItem, "codcliente") %>
</td>
<td>
<%# DataBinder.Eval(Container.DataItem, "razaosocial") %>
</td>
<td>
<%# DataBinder.Eval(Container.DataItem, "cidade") %>
</td>
<td class="text-center">
<a class='btn btn-info btn-xs' href="#"><span class="glyphicon glyphicon-edit"></span> Editar</a>
<a href="#" class="btn btn-danger btn-xs"><span class="glyphicon glyphicon-remove"></span> Excluir</a></td>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</div>
</div>
</form>
</body>
</body>
Code of the aspnet C screen#
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace SITE_SERVICO.cliente
{
public partial class ListaCliente : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
BancoDados.BancoDados bd = new BancoDados.BancoDados();
SqlDataReader dtCliente = bd.ListarClientes();
rptCliente.DataSource = dtCliente;
rptCliente.DataBind();
}
}
}
Can someone help me?
Thank you, Marcelo. But in the bank I put the image and not the way
– Rodrigo Storti de Oliveira