I am attempting to create linkbuttons dynamically using the following code:
Dim arCategory As New ArrayList()
Create new category objects and load into arraylist
While drCategory.Read
arCategory.Add(New Category(drCategory.Item("Description"), drCategory.Item("CategoryKey")))
End While
Create new LinkButtons and load them into an arraylist and set the text attributes
Dim i As Integer = 0
Dim arLnkBtn As New ArrayList()
While (arCategory.Count > i)
arLnkBtn.Add(New LinkButton())
arLnkBtn(i).Text = arCategory(i).Title & " " & arCategory(i).Key & "<br />"
i = i + 1
End While
DataList1.DataSource = arLnkBtn
drCategory.Close()
SqlConnection1.Close()
Page.DataBind()
I have tried to bind the arraylist of LinkButtons to DataLists, Repeaters, Listboxes, and datagrids with no success. The LinkButtons exist in arLnkBtn and the text attributes are created successfully, but they do not display properly in the controls.
Thanks,
kelly_d
Dim arCategory As New ArrayList()
Create new category objects and load into arraylist
While drCategory.Read
arCategory.Add(New Category(drCategory.Item("Description"), drCategory.Item("CategoryKey")))
End While
Create new LinkButtons and load them into an arraylist and set the text attributes
Dim i As Integer = 0
Dim arLnkBtn As New ArrayList()
While (arCategory.Count > i)
arLnkBtn.Add(New LinkButton())
arLnkBtn(i).Text = arCategory(i).Title & " " & arCategory(i).Key & "<br />"
i = i + 1
End While
DataList1.DataSource = arLnkBtn
drCategory.Close()
SqlConnection1.Close()
Page.DataBind()
I have tried to bind the arraylist of LinkButtons to DataLists, Repeaters, Listboxes, and datagrids with no success. The LinkButtons exist in arLnkBtn and the text attributes are created successfully, but they do not display properly in the controls.
Thanks,
kelly_d