Solved

How do I create an array of Hyperlinks???

Posted on 2008-06-26
1
1,004 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

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…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

632 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