Bonjour à tous,
J'éprouve quelques difficultés à insérer une ligne dans un tableau dynamiquement pour afficher un label, suivi d'une textBox.
Voici le code :
Mon tableau :
Le code le chargeant :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 <table align="center" id="tblOrderCategory" cellspacing="2" cellpadding="2" summary="Category Details Design Table" border="0" runat="server"> </table>
Le tableau marche bien si je l'attribue à une table créée dynamiquement, mais pas sur une table présente dans mon fichier .ascx
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 While reader.Read() Dim row As New TableRow Dim cell1 As New TableCell With cell1 .Width = 250 End With Dim cell2 As New TableCell Dim lblCat As New Label With lblCat .Text = reader.GetString(1) .ID = "lbl" & reader.GetValue(0) .CssClass = "SubHead" End With Dim txtBox As New TextBox With txtBox .Text = reader.GetValue(2).ToString() .ID = "txt" & reader.GetValue(0) .Width = 20 .MaxLength = 2 End With cell1.Controls.Add(lblCat) cell2.Controls.Add(txtBox) row.Controls.Add(cell1) row.Controls.Add(cell2) tblOrderCategory.Controls.Add(row) tblOrderCategory.Controls.Add(row) End While
J'obtiens cette erreur :
Merci pour votre aideSystem.ArgumentException: 'HtmlTable' cannot have children of type 'TableRow'. at System.Web.UI.HtmlControls.HtmlTable.HtmlTableRowControlCollection.Add(Control child) at DotNetNuke.Modules.References.AddReferences.Page_Load(Object sender, EventArgs e) in C:\dnn\DesktopModules\References\AddReferences.ascx.vb:line 131![]()
Partager