repeater裡面置入buttom和HtmlInputCheckBox,
點選buttom後將HtmlInputCheckBox有選取的項目做動作
<ItemTemplate>
<input id="checkbox" type="checkbox" name="checkbox" value='<%#Eval("ID") %>' runat="server"/>
<asp:ImageButton ID="ImageButton1" runat="server" CommandName="2" ImageUrl="/test/images/delete_all.png" /> </ItemTemplate>
Protected Sub Ret_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles Ret.ItemCommand
If e.CommandName = 2 Then
For Each ri As RepeaterItem In Ret.Items
If ri.ItemType = ListItemType.Item OrElse ri.ItemType = ListItemType.AlternatingItem Then
If e.Item.FindControl("checkbox") IsNot Nothing Then '添加此句
Dim ch As HtmlInputCheckBox = CType(e.Item.FindControl("checkbox"), HtmlInputCheckBox)
If ch.Checked Then '錯在這行
Response.Write("<script>alert('1')</script>")
Else
Response.Write("<script>alert('2')</script>")
End If
End If
End If
Next
End If
End Sub