I'm trying to access the ID as FindControl but it doesn't return the value, giving me the object not instantiated error. How can I access its ID? I've tried several things and so far I don't know how to solve this problem. PS: I'm new to C# programming
ASP.NET
<ItemTemplate >
<tr id="item" runat="server" class="row">
<td class="first">
<asp:Label ID="lblNumero_titulo" runat="server" Text='<%# Eval("numero_titulo") %>' /><br />
</td>
<td><%# Eval("razao_social") %></td>
<td><%# Eval("hora_entrega")%></td>
<td><%# Eval("quem_recebeu")%></td>
<td>
<asp:CheckBox ID="testecb" runat="server" /> </td>
<td>
<asp:Label ID="lblCodEntrega"Visible="false" runat="server" Text='<%# Eval("cod_entrega") %>' /><br />
</td>
</tr>
</ItemTemplate>
C#
protected void btnPesquisar_Click(object sender, EventArgs e)
{
limpaCampos();
using (PrincipalDataContext pdc = new PrincipalDataContext())
{
if (!string.IsNullOrEmpty(txtCodRomaneio.Text))
{
var romaneios = pdc.z_stp_anb_transp_receb(Convert.ToInt32(txtCodRomaneio.Text)).ToList();
var r = romaneios.First();
var check = lvNotas.FindControl("testecb") as CheckBox;
if (romaneios != null)
{
if (r.status == 1)
{
check.Checked = true;
check.Enabled = false;
}
lvNotas.DataSource = romaneios;
lvNotas.DataBind();
}
else
{
ScriptManager.RegisterStartupScript(this, typeof(Page), UniqueID, "alert('Romaneio não encontrado!')", true);
}
}
}
}
Aucun commentaire:
Enregistrer un commentaire