Click here to Skip to main content
14,775,228 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys,

i have a button in a repeater with update panel.

now, the problem is, the triggers controlID is not able get button id which in the repeater,

how to get this button id.

plz suggest me,

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>

<asp:Repeater ID="Repeater1" runat="server">
    <HeaderTemplate>
        <table class="table table-bordered table-hover">
            <thead class="bg-primary lt">
                <tr>
                    <th style="width: 50px;">
                        S.No.
                    </th>
                    <th>
                        Name
                    </th>
                    <th>
                        Position
                    </th>
                    <th>
                        Extension
                    </th>
                    <th>
                        Action
                    </th>
                </tr>
            </thead><tbody>
    </HeaderTemplate>

        <itemtemplate>
    <tr>
    <td><b>
    <%# Container.ItemIndex + 1 %></b>
    </td>
    <td><%# Eval("EmpName") %></td>
    <td><%# Eval("Position") %></td>
    <td><%# Eval("ExtensionNo") %></td>
    <td>
          <asp:LinkButton ID="btndel1" CssClass="btn btn-danger" runat="server" CommandName="delete"
          CommandArgument='<%# Eval("RecID") %>' ToolTip='Delete'
          OnClientClick="return confirm('Are you SURE you want to Delete this Ext?');"
          OnClick="btndel_Click">
         <span class="fa fa-trash-o"></span></asp:LinkButton>
        &nbsp
        <asp:LinkButton ID="btnedit1" CssClass="btn btn-info" runat="server" ToolTip="Edit"
        CommandArgument='<%# Eval("RecID") %>' OnClick="btnedit_Click" >
         <i class="fa fa-edit"></i></asp:LinkButton>

      </td>
    </tr>
    </itemtemplate>
    <Footertemplate>
        </tbody>
        </table>
    </FooterTemplate>
</asp:Repeater>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btndel1" /> //throwing error id not found
<asp:AsyncPostBackTrigger ControlID="btnedit1"  /> // same error
</Triggers>
</asp:UpdatePanel>



thanks
Posted
Updated 25-May-14 21:38pm
v3
Comments
Kornfeld Eliyahu Peter 25-May-14 16:14pm
   
Please show the code that try to access the button using it's id...
abdul subhan mohammed 26-May-14 2:36am
   
<asp:AsyncPostBackTrigger ControlID="btndel1" /> //throwing error id not found
<asp:AsyncPostBackTrigger ControlID="btnedit1" /> // same error
*A control with ID 'btndel1' could not be found for the trigger in UpdatePanel 'UpdatePanel1'.
ZurdoDev 25-May-14 22:13pm
   
Where's your code?
abdul subhan mohammed 26-May-14 2:36am
   
<asp:AsyncPostBackTrigger ControlID="btndel1" /> //throwing error id not found
<asp:AsyncPostBackTrigger ControlID="btnedit1" /> // same error
*A control with ID 'btndel1' could not be found for the trigger in UpdatePanel 'UpdatePanel1'.

1 solution

You are a fortunate man - I just wrote an article that explains how Control ID works in ASP.NET templates...
Understanding ASP.NET Templates[^]
Think about it - you have several buttons, that supposedly have the same ID - sot to which control do you want to bind the trigger?
If you read MSDN about AsyncPostBackTrigger[^] - you can see that you have to provide a specific ID, that identifies a single control!
Probably your only (and best) option is to do it from the code-behind - http://msdn.microsoft.com/en-us/library/system.web.ui.scriptmanager.registerasyncpostbackcontrol.aspx[^]
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900