I have this linkbutton:
<td><asp:LinkButton ID="lkbEnviarDocumentos" CssClass="acessos" Text="Documentos" runat="server" /></td>} %>
When this condition is true if(hdfTipoUsuario.Value == "2")
I have to change the Text of
Documents
for
Validate Documents
How do I do this? I've tried it like this:
(LinkButton)e.Item.FindControl("lkbEnviarDocumentos").Text
but this does not work. Not that way, either. lkbEnviarDocumentos.Text = "Validar Documentos";
What is the correct way to do this? I tried in Asp.Net, putting an IF there, but he did not accept it, he said that there are two ID's alike, ie he did not consider in the if or that or that, that way.
<% if(hdfTipoUsuario.Value != "2"){%>
<td><asp:LinkButton ID="lkbEnviarDocumentos" CssClass="acessos" Text="Documentos" runat="server" /></td>} %>
<% }
else
{%>
<td><asp:LinkButton ID="lkbEnviarDocumentos" CssClass="acessos" Text="Validar Documentos" runat="server" /></td>
<% } %>
I almost forgot: All this is within itemcommand
of repeater
.
Understanding well, I think the itemcommand is no place for this, right?
I made this DataBound and now it gives error, saying: Object reference not set to an instance of an object.
protected void rptBens_ItemDataBound(object source, RepeaterItemEventArgs e)
{
//Declarações
LinkButton vlkbDocumentos = null;
//Instâncias e Inicializações
vlkbDocumentos = (LinkButton)e.Item.FindControl("lkbEnviarDocumentos");
//Desenvolvimento
if (vlkbDocumentos.Text != string.Empty)
{
if (hdfTipoUsuario.Value == "2")
{
vlkbDocumentos.Text = "Validar Documentos";
}
}
}
I was doing it wrong, but I fixed it. The if is now and does not give more error:
if (vlkbDocumentos != null)
{
if (hdfTipoUsuario.Value == "2")
{
vlkbDocumentos.Text = "Validar Documentos";
}
}
It happens that even this way, the following is happening: The button is repeated, one on top of the other. One with text Documentos
and below that Validar Documentos
, doing the above mentioned form.