Change Text attribute of a linkbutton within a table in a repeater

1

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.

    
asked by anonymous 27.01.2015 / 17:48

1 answer

1

I solved the problem. Actually my IF is correct. Turns out it was inside a table, it broke the layout and honestly it looked like there were two buttons. As he was very tight, when he inspected, he just marked the top. Just discovered, when the colleague who is designer spoke, for me to increase the width of the and was when I realized it was just a button. Closed case.

    
27.01.2015 / 19:55