Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How do I create an array of Hyperlinks???

Posted on 2008-06-26
1
Medium Priority
?
1,009 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 375 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
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 …
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…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

705 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