Question

Need a help with asp.net

This is my code:

<asp:Repeater runat="server" ID="RepeaterContents">
    <ItemTemplate>
        <tr>
            <td valign="middle"><%#Eval("Title")%> </td>
            <td class="txt"><%#Util.ExibirStatus(Eval("Active").ToString()) %></td>
            <td class="txt"><a href="ContentDetail.aspx?Id=<%#Eval("ContentId")%>">Editar</a>&nbsp;&nbsp;&nbsp;
                <asp:LinkButton runat="server" ID="**LinkButtonExcluir**" OnCommand="Excluir" OnClientClick="javascript:return(confirm('Deseja realmente excluir este conteúdo?'))" CommandArgument='<%#Eval("ContentId")%>'>Excluir</asp:LinkButton>
            </td>
        </tr>
    </ItemTemplate>
</asp:Repeater>

and my .CS

private void EntitiesLoad(int id)
{
    repository = CreateRepository<IPageRepository>();
    page = repository.SelectById(id);

    if (page != null && page.ParentPage != null)
    {
        TextBoxTitulo.Enabled = true;
    }

    switch (id)
    {
        case 10:
            EscondePanels(PanelImagem, PanelMaster, PanelConteudo);
            **LinkButtonExcluir**.Enabled = false;
            break;

Why does not recognize the element Asp.Net?

Was it helpful?

Solution

** appreciate me by vote, if you like this answer **

Servy has a point... so search by ID. if you have a textbox in your repeater named tbxKey. The same for a LinkButton.

just call the repeater like this and give the textbox and LinkButton a value.

example '

 foreach (RepeaterItem item in repeatername.Items)
        {
          ((TextBox)item.FindControl("tbxKey")).Text = "hello";
          ((LinkButton) item.FindControl("LinkButton")).Enabled = false;
        }

' I'll have to put the whole object (type + item.findcontrol) in extra () then it will get the type's properties.

BTW, think you'll want to get ride of the stars in your name

Hope it helps you

OTHER TIPS

Because there isn't just one link button. There is one for each row. You can only refer to that item by ID from within the context of that row.

To enable/disable all (or some) of the links, you should databind and additional value, a boolean, indicating whether it should be shown. You can then bind that additional column to the Visible property of the link.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top