Question Add link in ArrayList

ebtihal

Member
Joined
Mar 14, 2011
Messages
21
Programming Experience
Beginner
hi ..
I tried to add a links ,html link, in ArrayList in vb, then I retrieved that links to display it in label. Like this:

VB.NET:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
 
'initilize connection string
con.ConnectionString = ConfigurationManager.ConnectionStrings("DalilucDBConnectionString").ConnectionString
 
'select maximum news id to display latest news
sql = String.Format("select news_id, contents from news ")
 
'Create Command object
thisCommand = New SqlCommand(sql, con)
 
'Open connection
con.Open()
 
 
'Execute query
Dim thisReader As SqlDataReader = thisCommand.ExecuteReader
thisCommand.Dispose()
 
While thisReader.Read
 
 
newsID = Convert.ToString(thisReader.GetValue(0))
newsContent = Convert.ToString(thisReader.GetValue(1))
contentAry.Add("<a   ' href = 'NewsDetails.aspx?' " & newsID & " >" & newsContent & "</a>")
 
End While


but i have a problem when i add vb variable "NewID" to html href , cuz its return nothing !
Although the "newsContent " is wirked well.
i don't know if it is a correct format !
or if there is any other way to add link in ArrayList.

thanx
 
Last edited:
Your anchor tag code doesn't seem to make any sense. I would think that something like this would be more appropriate:
VB.NET:
contentAry.Add(String.Format("<a href='NewsDeatils.aspx?id={0}'>{1}</a>", thisReader(0), thisReader(1)))
Also, unless you're using VS.NET 2002 or 2003, you should not be using an ArrayList. If you want a collection of Strings then use a List(Of String).
 
Back
Top