imports system.io . . . Protected WithEvents Table1 As System.Web.UI.WebControls.Table . . . Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Placez ici le code utilisateur pour initialiser la page Dim Row As New TableRow Dim i As Integer = 0 Dim Cell As New TableCell For Each File As String In System.IO.Directory.GetFiles(Server.MapPath("")) Dim FI As New FileInfo(File) Cell = New TableCell Dim Check As New CheckBox Check.ID = "check" & FI.Name Cell.Controls.Add(Check) Dim Literal As New Literal Literal.Text = FI.Name Cell.Controls.Add(Literal) Row.Cells.Add(Cell) i += 1 If i = 3 Then i = 0 Table1.Rows.Add(Row) Row = New TableRow End If Next Row = New TableRow Dim LeBouton As New Button LeBouton.Text = "valider" 'On lie le click du bouton à l'evenement on l'ajoute au placeholder AddHandler LeBouton.Click, AddressOf LeBouton_Click Cell = New TableCell cell.Controls.Add(LeBouton) Row.Cells.Add(cell) Table1.Rows.Add(Row) Table1.DataBind() Table1.Dispose() End Sub Private Sub LeBouton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim Coll As Collections.Specialized.NameValueCollection = Request.Form Dim Al As New ArrayList For Each c As String In Coll If Left(c, 5) = "check" Then Response.Write(c & " ") Al.Add(c) End If Next Session("CheckBox") = Al Response.Redirect("RecupCheckbox.aspx") End Sub
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Placez ici le code utilisateur pour initialiser la page Dim Al As ArrayList = Session("CheckBox") Response.Write("Vous avez cocher : ") For Each s As String In Al Response.Write("<li>" & s & " </li>") Next Response.Write("") End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question