Solved

How do I create an array of Hyperlinks???

Posted on 2008-06-26
1
982 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
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

743 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

15 Experts available now in Live!

Get 1:1 Help Now