我有3个嵌套重复,在第三个中继器中我有一个asp链接按钮, 我的问题是,当我点击按钮时,它无法触发其OnClick事件
HTML代码
<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") %>
<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>
功能背后的代码
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
我已经分享了我的代码,请帮我解释我将如何点击按钮上的点击事件
答案 0 :(得分:0)
试试这个
而不是
OnClick="btnFloor2_Click"
到
onclick="btnFloor2_Click();"
答案 1 :(得分:0)
你是否为OnItemCommand =“rptRooms_ItemCommand”中定义的事件处理程序编写了代码?应该像
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
您为其他活动发布的代码
Try
"ajax_showTooltip('ToolTip.aspx?type=Rm&RID=" + RoomID.ToString + "',this);return false")
看起来很破碎