Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need help with code behind and making a table to format data in straight rows and columns

Status
Not open for further replies.

DougP

MIS
Dec 13, 1999
5,985
US
this code works but the text boxes and labels go across the page instead of up and down in 2 columns
Code:
label1[     ]  label2[     ]    label3[     ]   label4[     ]
label5[     ]  label6[     ]    label7[     ]   label8[     ]
I need it to go down like this: what am I doing wrong?
label1[     ]  label5[     ]
label2[     ]  label6[     ]
label3[     ]  label7[     ]
label4[     ]  label8[     ]
Code:
            Dim objComm As SqlCommand
            Dim objReader As SqlDataReader
            ' Dim strSQL As String = "Select top 1 FieldName from forms_Main Order by UniqueID"
            Dim strSQL As String = "Select FieldName from forms_Main Where FormName = '" & Session("formsProLoadForm") & "'"
            strConn.Open()
            objComm = New SqlCommand(strSQL, strConn)
            objReader = objComm.ExecuteReader()
            If objReader.HasRows Then
                ThePlaceHolderContainer.Controls.Add(New LiteralControl("<asp:Table ID='Table1' runat='server'>"))
                Do While objReader.Read()
                    
                    ' Create a new Label, set the properties, and add to placeholder
                    TheRecordLabel = New Label
                    ThePlaceHolderContainer.Controls.Add(New LiteralControl("<asp:TableRow>"))
                    ThePlaceHolderContainer.Controls.Add(New LiteralControl("<asp:TableCell>"))
                    TheRecordLabel.ID = "lbl_" & objReader.GetString(0)

                    TheRecordLabel.Text = objReader.GetString(0)
                    ThePlaceHolderContainer.Controls.Add(TheRecordLabel)
                    ThePlaceHolderContainer.Controls.Add(New LiteralControl("</asp:TableCell>"))
                    ThePlaceHolderContainer.Controls.Add(New LiteralControl("<asp:TableCell>"))
                    ' Create a new textbox, set the properties, and add to placehodler
                    TheRecordTextBox = New TextBox()
                    TheRecordTextBox.ID = "txt_" & objReader.GetString(0)
                    'TheRecordTextBox.Style.
                    TheRecordTextBox.Text = ""
                    ThePlaceHolderContainer.Controls.Add(TheRecordTextBox)
                    'ThePlaceHolderContainer.Controls.Add(New LiteralControl("<br />"))
                    ThePlaceHolderContainer.Controls.Add(New LiteralControl("</asp:TableCell>"))
                    ThePlaceHolderContainer.Controls.Add(New LiteralControl("</asp:TableRow>"))
                    
                Loop
                ThePlaceHolderContainer.Controls.Add(New LiteralControl("</asp:Table>"))
            End If
            ' Add the placeholder to the Content Control (from Master)
            TheMasterContentControl.Controls.Add(ThePlaceHolderContainer)

DougP
 
ThePlaceHolderContainer.Controls.Add(New LiteralControl("<Table>")) 'using Standard HTML not asp:
Do While objReader.Read()
'For i = 0 To 10
' Create a new Label, set the properties, and add to placeholder
ThePlaceHolderContainer.Controls.Add(New LiteralControl("<tr>"))
ThePlaceHolderContainer.Controls.Add(New LiteralControl("<td>"))
TheRecordLabel = New Label
TheRecordLabel.ID = "lbl_" & objReader.GetString(0)
TheRecordLabel.Text = objReader.GetString(0)
ThePlaceHolderContainer.Controls.Add(TheRecordLabel)
ThePlaceHolderContainer.Controls.Add(New LiteralControl("</td>"))
' Create a new textbox, set the properties, and add to placehodler
ThePlaceHolderContainer.Controls.Add(New LiteralControl("<td>"))
TheRecordTextBox = New TextBox()
TheRecordTextBox.ID = "txt_" & objReader.GetString(0)
TheRecordTextBox.Text = "."
ThePlaceHolderContainer.Controls.Add(TheRecordTextBox)
'ThePlaceHolderContainer.Controls.Add(New LiteralControl("<br />"))
ThePlaceHolderContainer.Controls.Add(New LiteralControl("</td>"))
ThePlaceHolderContainer.Controls.Add(New LiteralControl("<tr>"))
'Next
Loop
ThePlaceHolderContainer.Controls.Add(New LiteralControl("</Table>"))

DougP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top