7
How can I catch the Text
of my Label
that is inside a ListView
without using the FindControl
(Item.FindControl("lblCodigoEdit") as Label).Text
), or is access directly
the value it has in mine 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);
}
In 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 perform better since with the FindControl
all control is charged when in reality I just needed the Text
of control.