ASP.NET如何在嵌套下的repeater中执行linkbutton点击事件? 255
前台代码:<asp:Repeaterrunat="server"ID="repeater1"OnItemDataBound="repeater1_ItemDataBoun...
前台代码:
<asp:Repeater runat="server" ID="repeater1" OnItemDataBound="repeater1_ItemDataBound">
<itemtemplate>
<asp:Label ID="LB" runat="server" Text=<%#Container.DataItem("wmlbID")%> Visible="false"></asp:Label>
<%#Container.DataItem("biaoti")%>
<asp:Repeater runat="server" ID="repeater2">
<itemtemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CssClass="linkBtn" CommandName="Inser" CommandArgument=<%#Container.DataItem ("wmcpID") %> Height="50px" Width="50px">加入购物车</asp:LinkButton>
</itemtemplate>
</asp:Repeater>
</itemtemplate>
</asp:Repeater>
后台代码:
'查询商品类别下的商品信息
Protected Sub repeater1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles repeater1.ItemDataBound
If (e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem) Then
Dim rep2 As Repeater = e.Item.FindControl("Repeater2")
Dim Mylb As Label = e.Item.FindControl("LB")
Dim MylbID As String = Mylb.Text
'生成一个NET_TO_SQL类的实例
Dim cs As New NET_TO_SQL1
'打开数据库
cs.open_MyConnection()
Dim myaa1 = cs.get_MyDataReader("select * from wmcp where wmlbID='" + MylbID + "'")
rep2.DataSource = myaa1
rep2.DataBind()
cs.MyDataReader.Close()
cs.close_MyConnection()
End If
End Sub
问题是:Repeater2的数据已经绑定好了,现在我想做的是:当我点击LinkButton1的时候,将repeater2里面的相关数据插入到数据库中,如何实现?我知道肯定会是在repeater2的ItemCommand下完成,但是嵌套下的repeater2的itemCommand事件不会写!请各位大佬帮帮忙! 展开
<asp:Repeater runat="server" ID="repeater1" OnItemDataBound="repeater1_ItemDataBound">
<itemtemplate>
<asp:Label ID="LB" runat="server" Text=<%#Container.DataItem("wmlbID")%> Visible="false"></asp:Label>
<%#Container.DataItem("biaoti")%>
<asp:Repeater runat="server" ID="repeater2">
<itemtemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CssClass="linkBtn" CommandName="Inser" CommandArgument=<%#Container.DataItem ("wmcpID") %> Height="50px" Width="50px">加入购物车</asp:LinkButton>
</itemtemplate>
</asp:Repeater>
</itemtemplate>
</asp:Repeater>
后台代码:
'查询商品类别下的商品信息
Protected Sub repeater1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles repeater1.ItemDataBound
If (e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem) Then
Dim rep2 As Repeater = e.Item.FindControl("Repeater2")
Dim Mylb As Label = e.Item.FindControl("LB")
Dim MylbID As String = Mylb.Text
'生成一个NET_TO_SQL类的实例
Dim cs As New NET_TO_SQL1
'打开数据库
cs.open_MyConnection()
Dim myaa1 = cs.get_MyDataReader("select * from wmcp where wmlbID='" + MylbID + "'")
rep2.DataSource = myaa1
rep2.DataBind()
cs.MyDataReader.Close()
cs.close_MyConnection()
End If
End Sub
问题是:Repeater2的数据已经绑定好了,现在我想做的是:当我点击LinkButton1的时候,将repeater2里面的相关数据插入到数据库中,如何实现?我知道肯定会是在repeater2的ItemCommand下完成,但是嵌套下的repeater2的itemCommand事件不会写!请各位大佬帮帮忙! 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询