Solved

Change hyperlinkfield in gridview in ASP.net **specifically VB**

Posted on 2011-03-23
3
843 Views
Last Modified: 2012-06-27
I need the VB version of this.  What I want to do is take the value of one cell in a gridview row and add that value to a hyperlinkfield.

For each row in this gridview, I want to do this to the first cell:

hyperlinkfield = "http://myaddress/"+ ValueOfCell5

I see how to do this in C# (example below), I have been unable to get a version of it to work in ASP.NET VB


protected void gridCaseMember_RowDataBound(object sender, GridViewRowEventArgs e){

 if (e.Row.RowType == DataControlRowType.DataRow){
 HyperLink myLink = (HyperLink)e.Row.Cells[0].Controls[0];
 
myLink.NavigateUrl = “http://www.bing.com”;    }
 
}

Open in new window

0
Comment
Question by:Zipbang
  • 2
3 Comments
 
LVL 13

Accepted Solution

by:
Rick earned 500 total points
ID: 35202891
Try This:
If e.Row.RowType = DataControlRowType.DataRow Then

  Dim lnk As New HyperLink

  With lnk
    .NavigateUrl = "http://myaddress/" & e.Row.Cells(5).Text
    .Text = e.Row.Cells(5).Text
  End With

  With e.Row.Cells(0)
    .Text = ""
    .Controls.Add(lnk)
  End With

End If

Open in new window

0
 
LVL 13

Expert Comment

by:Rick
ID: 35202922
And if you already had a Hyperlink in cell 0:

If e.Row.RowType = DataControlRowType.DataRow Then

DirectCast(e.Row.Cells(0).FindControl("YourHyperLink"), Hyperlink).Text = DirectCast(e.Row..Cells(5).Text

DirectCast(e.Row.Cells(0).FindControl("YourHyperLink"), Hyperlink).NavigateUrl = "http://myaddress/" & e.Row.Cells(5).Text

End If
0
 

Author Closing Comment

by:Zipbang
ID: 35206063
This is perfect!  Great answer and couldn't have been any quicker.

Thanks!!
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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 …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

747 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

9 Experts available now in Live!

Get 1:1 Help Now