test.aspx
<asp:DataList
ID="DataList1" runat="server" DataKeyField="拜訪編號" DataSourceID="SqlDataSource1">
<ItemTemplate>
<asp:Label ID="lb_no"
runat="server" Text='<%# Eval("lb_no") %>' />
<asp:Button
ID="Button1" runat="server" Text="按鈕1" CommandName="TestButton"
/>
<asp:DataList ID="DataList2"
runat="server" DataSourceID="SqlDataSource2"
OnItemCommand="DataList2_ItemCommand" >
<ItemTemplate>
<asp:Label ID="lb_no2" runat="server" Text='<%#
Eval("no") %>' />
<asp:Button ID="Button1"
runat="server" Text="按鈕2" CommandName="TestButton2"
/>
</ItemTemplate>
</asp:DataList>
</ItemTemplate>
</asp:DataList>
test.aspx.vb
Public Sub DataList2_ItemCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs)
If e.CommandName = "TestButton2" Then
If e.CommandName = "TestButton2" Then
Dim dl As DataList = CType(e.Item.FindControl("DataList2"), DataList)
Dim lb_no As Label = CType(e.Item.FindControl("lb_no2"), Label)
End If
End Sub
Dim lb_no As Label = CType(e.Item.FindControl("lb_no2"), Label)
End If
End Sub
沒有留言:
張貼留言