I am attempting to dynamically create a profile page. Everything works fine except when I try to add the title (surrounded by <h2> tags) to the lbl control which is inserted in the select statement. Let me know if this is too confusing and I will attempt to explain further.
The point of the case statement is to create ‘1’ heading for a particular position.
mydiv = New System.Web.UI.HtmlControls.HtmlGenericControl("DIV")
tble.Rows.Add(trow)
tCell = New TableCell
tCell.ColumnSpan = 2
tCell.BackColor = Drawing.Color.Tan
trow.Cells.Add(tCell)
Select Case aUsers(x).Title
Case 1
If title <> "Members" Then
title = "Members"
End If
Case 2
If title <> "Treasurer" Then
title = "Treasurer"
End If
Case 3
If title <> "Secretary" Then
title = "Secretary"
End If
Case 4
If title <> "Membership Committee" Then
title = "Membership Committee"
End If
Case 5
If title <> "Vice President" Then
title = "Vice President"
End If
Case 6
If title <> "President" Then
title = "President"
End If
Case Else
End Select
mydiv.InnerHtml = "<h2>" & title & "</h2>"
tCell.Controls.Add(mydiv)
trow = New TableRow
tCell = New TableCell
mydiv = New System.Web.UI.HtmlControls.HtmlGenericControl("DIV")
tble.Rows.Add(trow)
If i’m not reading your code wrong, looks like you create an instance of label inside the case and set the text, but then for your second row your using the same instance and setting the text property.
You need to set lbl = New Label when you set your new rows and cells.