How can I get the Text
of my Label
that is within a ListView
without using the FindControl
( Item.FindControl("lblCodigoEdit") as Label).Text
), ie directly access
the value you have in my lblCodigoEdit
?
foreach (var Item in livCamposForm.Items)
{
var dataKey = livCamposForm.DataKeys[Item.DataItemIndex];
if (dataKey == null)
continue;
var IdCampoFormulario = (Int32)dataKey.Value;
var qrCampsForm = DBCtx.tb_CamposFormulario.Find(IdCampoFormulario);
Int32 Conta = Convert.ToInt32((Item.FindControl("lblCodigoEdit") as Label).Text);
}
No ListView
<ItemTemplate>
<tr class="<%#setClass(Container.DataItem)%>">
<td>
<asp:Label ID="lblCodigoEdit" class="<%#setClass(Container.DataItem)%>" runat="server"
Text='<%# Eval("Codigo")%>' />
</td>
<td>
The reason for this is to have a better performance since with FindControl
all the control is loaded when in fact I only needed the Text
of the control.