Question

I have 3 nested repeates, and in third repeater i have an asp link button, my question is when i click on button, it can't fire its OnClick event

HTML code

 <asp:UpdatePanel ID="UpdatePanelGrid" runat="server">
                            <ContentTemplate>
                                <table id="tblMultGridView" runat="server" cellspacing="0" cellpadding="0" width="100%"
                                    align="center" border="0">
                                    <tr>
                                        <td>
                                            <table style="width: 100%">
                                                <asp:Repeater runat="server" ID="rptFloors" EnableViewState="false">
                                                    <ItemTemplate>
                                                        <tr>
                                                            <td>
                                                                <%# DataBinder.Eval(Container.DataItem, "FloorNo")%>
                                                            </td>
                                                            <td>
                                                            </td>
                                                        </tr>
                                                        <asp:Repeater ID="rptApartment" runat="server" EnableViewState="false"  DataSource='<%# GetChildRelation(Container.DataItem,"Floor_Apartment")%>'>
                                                            <ItemTemplate>
                                                                <tr>
                                                                    <td>
                                                                        <a href="javascript: void(0)" onclick="popup('../BackEnd/Apartmentdocsgallery.aspx?AptID=<%# DataBinder.Eval(Container.DataItem,"ApartmentID")%>')">
                                                                            <img src="../images/roomview.png" border="0" /></a>
                                                                        <%-- <a  href="#dialog" name="modal" onclick="ShowApartmentDetail('Apartmentdocsgallery.aspx?AptID=<%# DataBinder.Eval(Container.DataItem, "ApartmentID") %>')">
<img src="../images/roomview.png" border="0"  />                                                       
 <img src="../images/roomview.png" border="0"  /></a>--%>
                                                                        <%#Eval("ApartmentNo") %>&nbsp;&nbsp;&nbsp;&nbsp;
                                                                        <br />
                                                                    </td>
                                                                    <td>
                                                                        <asp:Repeater ID="rptRooms" runat="server" EnableViewState="false" OnItemCommand="rptRooms_ItemCommand" OnItemDataBound="rptRoom_ItemDataBound" 
                                                                        DataSource='<%# GetChildRelation(Container.DataItem, "Apartment_Room")%>'>
                                                                            <ItemTemplate>
                                                                                <div class="greenbtn" id="divRoomBtn" runat="server" style="vertical-align: top;">
                                                                                    <asp:LinkButton ID="btnFloor2" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "RoomNO") %>'
                                                                                        OnClick="btnFloor2_Click" CommandName="Info" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "RoomID") %>'></asp:LinkButton>

                                                                                </div>

                                                                            </ItemTemplate>
                                                                        </asp:Repeater>
                                                                    </td>
                                                                </tr>
                                                            </ItemTemplate>
                                                        </asp:Repeater>
                                                    </ItemTemplate>
                                                </asp:Repeater>
                                            </table>
                                        </td>
                                    </tr>

                                </table>
                            </ContentTemplate>

                        </asp:UpdatePanel>

Code behind functionality of

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Try
        Dim ds As DataSet = obj.GetData()
        rptFloors.DataSource = ds
        rptFloors.DataBind()
    Catch ex As Exception
        Throw ex
    End Try

End Sub

Public Function GetChildRelation(ByVal dataItem As Object, ByVal relation As String) As DataView
    Dim drv As DataRowView = dataItem
    If drv IsNot Nothing Then
        Return drv.CreateChildView(relation)
    Else
        Return Nothing
    End If

End Function
Protected Sub btnFloor2_Click(ByVal sender As Object, ByVal e As System.EventArgs)
    Response.Redirect("OtherPage.aspx", False)
End Sub

Protected Sub rptRoom_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs)
    Try
  "ajax_showTooltip('ToolTip.aspx?type=Rm&RID=" + RoomID.ToString + "',this);return false")

    Catch ex As Exception
        lblMessage.Text = ex.Message.ToString
    End Try
End Sub

I have shared my code, please help me out that how i will fire me click event on button

No correct solution

OTHER TIPS

Try like this

instead of

OnClick="btnFloor2_Click"

to

onclick="btnFloor2_Click();"

did you wrote the code for the event handler you defined in OnItemCommand="rptRooms_ItemCommand" ? should be something like

Protected Sub rptRooms_ItemCommand(Sender As Object, e As RepeaterCommandEventArgs)
    If e.CommandName = "Info" Then
        Dim RoomID As Object = e.CommandArgument
        (do something with the argument)
    End If
End Sub 

the code you posted for the other event

Try
    "ajax_showTooltip('ToolTip.aspx?type=Rm&RID=" + RoomID.ToString + "',this);return false")

looks broken

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