how to add 3 checkbox per row in htmltable dynamically
-
Hi In my one of the application i am creating check box dynamically. for that purpose i am using html web server control. i am dynamically creating checkbox and it to table row and cell but i need only 3 checkbox per row when 4 checkbox added to the page it should come to next row how i can do this.My code is as follow.Please help me to solve this.
While dr.Read Dim chkbox As CheckBox = New CheckBox chkbox.Text = dr(0) chkbox.CssClass = "pagetext2inside" chkbox.ID = "chklang" & i Dim tabcell As TableCell = New TableCell Dim tabrow As TableRow = New TableRow tabcell.Controls.Add(chkbox) tabrow.Controls.Add(tabcell) chktable.Rows.Add(tabrow) i = i + 1 End While dr.Close()
Rahul
-
Hi In my one of the application i am creating check box dynamically. for that purpose i am using html web server control. i am dynamically creating checkbox and it to table row and cell but i need only 3 checkbox per row when 4 checkbox added to the page it should come to next row how i can do this.My code is as follow.Please help me to solve this.
While dr.Read Dim chkbox As CheckBox = New CheckBox chkbox.Text = dr(0) chkbox.CssClass = "pagetext2inside" chkbox.ID = "chklang" & i Dim tabcell As TableCell = New TableCell Dim tabrow As TableRow = New TableRow tabcell.Controls.Add(chkbox) tabrow.Controls.Add(tabcell) chktable.Rows.Add(tabrow) i = i + 1 End While dr.Close()
Rahul
Hi Rahul, I am not good in vb I think you can write the same as Dim tabrow As TableRow i = 0 While dr.Read Dim chkbox As CheckBox = New CheckBox chkbox.Text = dr(0) chkbox.CssClass = "pagetext2inside" chkbox.ID = "chklang" & i Dim tabcell As TableCell = New TableCell if (i mod 3)= 0 then if tabrow.Cells.Count > 0 then chktable.Rows.Add(tabrow) end if tabrow = New TableRow end if tabcell.Controls.Add(chkbox) tabrow.Controls.Add(tabcell) i = i + 1 End While dr.Close() if tabrow.Cells.Count > 0 then chktable.Rows.Add(tabrow) end if
Ullas Sadanandan