Solved

How do I create an array of Hyperlinks???

Posted on 2008-06-26
1
987 Views
Last Modified: 2013-11-05
I am trying to dynamically create multiple hyperlinks. The count is never the same due to the count of records that are to be displayed.


I get the following error

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:


Line 61:         For i = 0 To (myDataSet.Tables(1).Rows.Count - 1)
Line 62:            
Line 63:             PrevApp(i).NavigateUrl = "http://abc.com/WebApp/ave/aveWorkACase.aspx?WACID=" '+ myDataSet.Tables(1).Rows(i).Item(0).ToString
Line 64:             PrevApp(i).Text = myDataSet.Tables(1).Rows(i).Item(0).ToString
Line 65:             PrevAppHolder.Controls.Add(PrevApp(i))
 




Dim PrevApp As HyperLink() = New HyperLink(myDataSet.Tables(1).Rows.Count) {}

 

        

        For i = 0 To (myDataSet.Tables(1).Rows.Count - 1)

            

            PrevApp(i).NavigateUrl = "http://abc.com/WebApp/ave/aveWorkACase.aspx?WACID=" '+ myDataSet.Tables(1).Rows(i).Item(0).ToString

            PrevApp(i).Text = myDataSet.Tables(1).Rows(i).Item(0).ToString

            PrevAppHolder.Controls.Add(PrevApp(i))

            

        Next i

Open in new window

0
Comment
Question by:jrisi03
1 Comment
 
LVL 10

Accepted Solution

by:
orbulat earned 125 total points
ID: 21881766
how about do it in this way?
try not to define the array, instead, you declare a new Hyperlink object in each iteration

(i am not familiar with VB, but u can try to "New" a hyperlink in the for-loop)


 

        

        For i = 0 To (myDataSet.Tables(1).Rows.Count - 1)

            Dim PrevApp As HyperLink() = New HyperLink()

            PrevApp(i).NavigateUrl = "http://abc.com/WebApp/ave/aveWorkACase.aspx?WACID=" '+ myDataSet.Tables(1).Rows(i).Item(0).ToString

            PrevApp(i).Text = myDataSet.Tables(1).Rows(i).Item(0).ToString

            PrevAppHolder.Controls.Add(PrevApp(i))

            

        Next i

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ASP.NET reading ATOM 2 53
Replace &lt; with < 14 57
Server Error 11 48
Gridview alignment 1 12
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now