Good afternoon I have a listbox ( webcontrols
) in ASP.net
that I charge in the following way:
ListPatentesAsignadas.DataSource = patente.RecuperarPatenteFamilia(i,
Padre);
ListPatentesAsignadas.DataValueField = "Nombre";
ListPatentesAsignadas.DataBind();
I need each element of that selected control to pass the Id and its Name. But at the time of selecting it, I only find the position and the name. Is there any way to pass the data to an object?
For the moment I can achieve this but without success. Can you help me?
for (int i = 0;i< ListPatentesAsignadas.Items.Count; i++)
{
if (ListPatentesAsignadas.Items[i].Selected == true)
{
entidadPatente.IdPermiso = ListPatentesAsignadas.SelectedIndex;
entidadPatente.Nombre = ListPatentesAsignadas.Items[i].ToString();
}
}