Tengo una lista de Medicamentos que carga bien, muestra el código y su nombre pero al momento de mostrar el nombre de la farmacéutica no me lo muestra.
<script runat="server">
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<style type="text/css">
.style3
{
height: 17px;
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<h3>
Consulta los medicamentos en BiosFarma
</h3>
<p>
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
</p>
<table style="width: 100%;">
<tr>
<td class="style3">
</td>
<td class="style3">
</td>
</tr>
<tr>
<td>
<asp:Button ID="Button1" runat="server" Text="Listar Medicamentos" />
<asp:Repeater ID="RpMedicamento" runat="server" OnItemCommand="Repeater1_ItemCommand">
<ItemTemplate>
<table>
<tr bgcolor="#1d25d1">
<td>
Codigo:<asp:TextBox ID="txtcodigo_medicamento" runat="server" Text='<%# Bind("Codigo_medicamento") %>'></asp:TextBox>
<br />
</td>
<td>
Nombre:<asp:TextBox ID="txtnombre_med" runat="server" Text='<%# Bind("Nombre_medi") %>'></asp:TextBox>
<br />
</td>
<td>
Nombre de farmaceutica:<asp:TextBox ID="TxtNomFarmaceutica" runat="server" Text='<%# Bind(**"Una_farm.Nombre_farm"**) %>'></asp:TextBox>
<br />
</td>
<td>
<asp:Button ID="Button1" runat="server" CommandName="Seleccion" Style="text-align: center"
Text="Seleccion" />
</td>
</tr>
</table>
</ItemTemplate>
<AlternatingItemTemplate>
<table>
<tr bgcolor="#57b65f">
<td>
Codigo:<asp:TextBox ID="Txtncodigo" runat="server" Text='<%# Bind("Codigo_medicamento") %>'></asp:TextBox>
<br />
</td>
<td>
Nombre:<asp:TextBox ID="Txtnombre" runat="server" Text='<%# Bind("Nombre_medi") %>'></asp:TextBox>
<br />
</td>
<td>
Nombre de farmaceutica:<asp:TextBox ID="TxtNomFarmaceutica" runat="server" Text='<%# Bind("Una_farm") %>'></asp:TextBox>
<br />
</td>
<td>
<asp:Button ID="Button2" runat="server" CommandName="Seleccion" Style="text-align: center"
Text="Seleccion" />
</td>
</tr>
</table>
</ItemTemplate>
</AlternatingItemTemplate>
</asp:Repeater>
<br />
<br />
<asp:Label ID="lblinfo" runat="server"></asp:Label>
<br />
</td>
<td>
</td>
</tr>
<tr>
<td>
<asp:Xml ID="controlXml" runat="server" TransformSource="~/XSLT/Medicamento.xslt"
ViewStateMode="Enabled"></asp:Xml>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
</tr>
</table>
</asp:Content>
La clase Medicamento:
public class Medicamento
{
private int codigo_medicamento;
private string nombre_medi;
private string descripcion;
private string tipo;
private decimal precio;
private int stock;
private Farmaceutica una_farm;
//[DataMember]
public int Codigo_medicamento
{
get { return codigo_medicamento; }
set { codigo_medicamento = value; }
}
//[DataMember]
public string Nombre_medi
{
get { return nombre_medi; }
set
{
if (value.Length < 3 || value.Length > 50)
throw new Exception("Error: el nombre del medicamento debe ser entre 3 y 50 caracteres");
else
nombre_medi = value;
}
}
//[DataMember]
public string Descripcion
{
get { return descripcion; }
set
{
if (value.Length < 3 || value.Length > 100)
throw new Exception("Error: la descripción debe ser entre 3 y 100 caracteres.");
else
descripcion = value;
}
}
public string Tipo
{
get { return tipo; }
set
{
//if (value.Length < 3 || value.Length > 100)
// throw new Exception("Error: la descripcion debe ser entre 3 y 100 caracteres.");
//else
// tipo = value;
if (value == "Diabetico" || value == "Cardiologico" || value == "Otro")
tipo = value;
else
throw new Exception("Error: El tipo es incorrecto");
}
}
//[DataMember]
public decimal Precio
{
get { return precio; }
set
{
if (value < 0 || value > 99999999)
throw new Exception("Error: el precio debe ser mayor a 0.");
else
precio = value;
}
}
//[DataMember]
public int Stock
{
get { return stock; }
set
{
if (value <= 0 || value > 99999999)
throw new Exception("Error: el stock debe ser mayor o igual a 0.");
else
stock = value;
}
}
//[DataMember]
public Farmaceutica Una_farm
{
get { return una_farm; }
set
{
if (value == null)
throw new Exception("Error: debe asignarse una farmacéutica");
else
una_farm = value;
}
}
public Medicamento() { }
public Medicamento(int cod, string nom, string descr, string tipo, decimal precio, int st, Farmaceutica farm)
{
Codigo_medicamento = cod;
Nombre_medi = nom;
Descripcion = descr;
Tipo = tipo;
Precio = precio;
Stock = st;
Una_farm = farm;
}
}
}
La clase Farmaceutica
public class Farmaceutica
{
//atributos
private string nombre_farm;
private string direccion;
private string telefono;
private string email;
//propiedades
//[DataMember]
public string Nombre_farm
{
get { return nombre_farm; }
set {if (value.Length < 3 || value.Length > 50)
throw new Exception("Error: el nombre de la farmacia debe ser entre 3 y 50 caracteres");
else
nombre_farm = value; }
}
//[DataMember]
public string Direccion
{
get { return direccion; }
set
{
if (value.Length < 3 || value.Length > 50)
throw new Exception("Error: la dirección debe ser entre 3 y 50 caracteres");
else
direccion = value;
}
}
//[DataMember]
public string Telefono
{
get { return telefono; }
set
{
if (value.Length < 3 || value.Length > 50)
throw new Exception("Error: el teléfono debe ser entre 3 y 50 números");
else
telefono = value;
}
}
//[DataMember]
public string Email
{
get { return email; }
set
{
if ((value==null)&&(!Regex.IsMatch(value,"^(([\\w-]+\\.)+[\\w-]+|(([a-zA-Z]{1}|[\\w-]{2,}))@(([a-zA-Z]+[\\w.]+\\.){1,2}[a-zA-Z]{2,4})$")))
throw new Exception("Error: el email debe ser de 3 a 50 y debe tener ser xxxx@xxx.xxx");
else
email = value;
}
}
public Farmaceutica() { }
public Farmaceutica(string nombre_farm, string direccion, string telefono, string email)
{
Nombre_farm = nombre_farm;
Direccion = direccion;
Telefono = telefono;
Email = email;
}
}
}