0
I have this code: This rptAprovaDocumento
is a Repeater
public List<ENTSISRegistroPendencia> RegistrarPendencia()
{
CheckBox vchkTornarObrigatorio = null;
for (int i = 0; i < rptAprovaDocumento.Items.Count; i++)
{
vchkTornarObrigatorio = (CheckBox)rptAprovaDocumento.Items[i].FindControl("chkTornarObrigatorio");
if (vchkTornarObrigatorio != null)
{
if (!vchkTornarObrigatorio.Checked)
{
ventRegPendencia.IcDocObrigatorio = 0;
}
else
{
ventRegPendencia.IcDocObrigatorio = 1;
}
}
else
{
ventRegPendencia.IcDocObrigatorio = 0;
}
}
}
How it works. This repeater
has a table that lists these records. This checkbox appears in a certain situation. The first time the credit analyst will make his analysis he appears, with the word "Make It Mandatory". This is his text. When the analyst checks and returns to the stores, the shopkeeper can see this listed document that the analyst made mandatory. By uploading this document and returning it to the analyst, it now appears to the analyst no longer as a Checkbox (Make It Mandatory) plus two Radiobutton: Approve and Fail. Well, it turns out that in that position of "i" inside the Peater, the var vchkTornarObrigatorio
should come NULL, right? I thought to nullify all variables at the end of the FOR
, but I found it a bit tricky, because I already said I want the value of the var in the "i" position inside the Peater, according to the code posted. I think about initializing the var inside the FOR
, but I also smell Gambi, I’m not sure. It’s a problem of logic and I ask for help from colleagues to solve this junk. How to nullify this var inside the for.
<asp:Repeater ID="rptAprovaDocumento" runat="server"
onitemdatabound="rptAprovaDocumento_ItemDataBound">
<HeaderTemplate>
<table width="1000">
<thead>
<th width="400">
Tipos de documento
</th>
<th width="150">
</th>
<th>
</th>
</thead>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:HiddenField ID="hdfCdTipoDocumento" runat="server" Value='<%# Eval("CdTipoDocumento")%>' />
<asp:HiddenField ID="hdfCdPendencia" runat="server" Value='<%# Eval("CdPendencia")%>' />
<asp:HiddenField ID="hdfCdDocumento" runat="server" Value='<%# Eval("CdDocumento")%>' />
<asp:HiddenField ID="hdfIcAprovado" runat="server" Value='<%# Eval("IcAprovado")%>' />
<asp:HiddenField ID="hdfIcDocObrigatorio" runat="server" Value='<%# Eval("IcDocObrigatorio")%>' />
<asp:HiddenField ID="hdfCdMotivo" runat="server" Value='<%# Eval("CdTipoMotivoRecusa")%>' />
<%--<strong><a href="/UpLoads/<%# Eval("DsPathDocumento")%>" class="linkUpload"><%# Eval("NmTipoDocumento")%></a></strong>--%>
<strong><a <%# Eval("DsPathDocumento") != null && !String.IsNullOrEmpty(Eval("DsPathDocumento").ToString()) ? String.Concat("href='/UpLoads/", Eval("DsPathDocumento"), "'","class='linkUpload'") : "style='cursor: default; color:#000000;' class='disabled'" %>>
<%# Eval("NmTipoDocumento") %>
</a></strong>
<asp:Label ID="lblDtCriacao" Text='' runat="server" /><br />
<asp:Label ID="lblNmObrigatorio" Text='<%# Eval("NmTipoObrigatorio") %>' runat="server" Font-Bold="True" />
</td>
<td>
<asp:RadioButtonList ID="rbIctAprovado" CssClass="radiobuttonAprovaReprova" onclick="javascript:MostraEscondeControle(this);"
runat="server" AutoPostBack="false" TextAlign="left" RepeatColumns="0" RepeatDirection="Vertical"
CausesValidation="False" OnSelectedIndexChanged="rbIctAprovado_SelectedIndexChanged" RepeatLayout="UnorderedList">
<asp:ListItem Value="1">Aprovar</asp:ListItem>
<asp:ListItem Value="0">Reprovar</asp:ListItem>
</asp:RadioButtonList>
<asp:CheckBox ID="chkTornarObrigatorio" runat="server" Text="Tornar Obrigatório" />
<br />
<asp:DropDownList ID="cmbCdMotivoRecusa" runat="server" Enabled="false" AutoPostBack="false"></asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="É necessário aprovar ou reprovar este documento para prosseguir."
ControlToValidate="rbIctAprovado" ValidationGroup="grupoAprovaReprova" Text=""></asp:RequiredFieldValidator>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
can post the Markup of these Repeater?
– Tobias Mesquita
I edited and posted Markup.
– pnet
I’m not seeing any condition that makes chkTornarObrigatorio inactive, invisible or nonexistent, as you’re hiding the same?
– Tobias Mesquita
Could you put the code snippet where the
chkTornarObrigatorio
is disabled or removed?– Tobias Mesquita
It is not removed. Only it appears or not, according to what the analyst did. I think I should change my logic there in the case, ie, I will create a method that takes the situation of the document in a previous analysis, then yes, I know that it can not change its status ever again.
– pnet
then in this case you should check the property
Visible
, onechkTornarObrigatorio.Visible
in place ofvchkTornarObrigatorio != null
must solve– Tobias Mesquita
I will test and put. I didn’t even think about it. If you solve, post this comment as an answer to finish.
– pnet
It worked in one part and related to the initial post solved, but does not conclude the problem, but is something else. Post your comment as an answer to end this post.
– pnet