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>
<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?
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.
** 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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.