<%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <script runat="server"> public class MyRow : System.Web.UI.WebControls.TableRow { public MyRow(string param1, string param2) { TableCell Cell1 = new TableCell(param1); TableCell Cell2 = new TableCell(param2); this.Cells.Add(Cell1); this.Cells.Add(Cell2); } } void Page_Load(object sender, EventArgs e) { Table MyTable = new Table(); TableRow MyRow; foreach (CheckBox Check in CheckBoxCollection) { if (Check.Checked) { MyRow = new MyRow("Cyril", "Durand"); MyTable.Rows.Add(MyRow); } } PlaceHolder1.Controls.Add(MyTable); } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> </head> <form id="form1" runat="server"> </form> </html>
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question<%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <script runat="server"> public class MyRow : System.Web.UI.WebControls.TableRow { public MyRow(string param1) { TableCell Cell = new TableCell("rien"); this.Cells.Add(Cell); Cell = new TableCell(param1); this.Cells.Add(Cell); } } void Page_Load(object sender, EventArgs e) { Table MyTable = new Table(); TableHeaderRow HeaderRow = new TableHeaderRow(); TableHeaderCell THC = new TableHeaderCell(); THC.Text = @"pas grand chose"; HeaderRow.Cells.Add(THC); THC = new TableHeaderCell(); THC.Text = @"Valeur du CheckBox"; HeaderRow.Cells.Add(THC); MyTable.Rows.Add(HeaderRow); TableRow myRow; foreach (ListItem Check in ((CheckBoxList)Session["CheckBoxList"]).Items) { if (Check.Selected) { myRow = new MyRow(Check.Text); MyTable.Rows.Add(myRow); } } PlaceHolder1.Controls.Add(MyTable); } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Untitled Page</title> </head> <form id="form1" runat="server"> </form> </html>
<%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <script runat="server"> void Button1_Click(object sender, EventArgs e) { Session["CheckBoxList"] = (object)this.CheckBoxList1; Response.Redirect(ResolveClientUrl("Default.aspx")); } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> </head> <form id="form1" runat="server"> </form> </html>