Question

In my ASP.NET Web Forms I would like to get the DataNavigateUrlFields from the HyperLinkField control.

In order to get the control I use the following code in the RowDataBound event:

If e.Row.Cells(n).Controls(0).GetType().ToString() = "System.Web.UI.WebControls.HyperLink" Then
     Dim linkDownload As HyperLink = DirectCast(e.Row.Cells(n).Controls(0), HyperLink)

The problem is that I get an HyperLink already "filled" so the DataNavigateURLFormatString (myPage.aspx?downloadId = {0}) and DataNavigateUrlFields (downloadGuid) are already combined in the HyperLink.NavigateUrl property.

Is there any way to get the DataNavigateUrlFields property? In case there is not, is there any function to extract the downloadGuid value from HyperLink.NavigateUrl (in short treating the NavigateUrl as a QueryString)?

VB is preferred but also answers in C# are appreciated

Was it helpful?

Solution

If you got the url, you can use Url class to manipulate it. It also allows to extract parameters and values. There's regexp option available too.

But where's downloadGuid in DataNavigateUrlFields (downloadGuid) coming from? You should get your bound object in the RowDataBound event parameters, if downloadGuid is the property, you can grap if from there.

Anyways, full event code will certainly help.

OTHER TIPS

Why can not you get it like

 if(e.Row.RowType==DataControlRowType.DataRow)
                Response.Write(((DataRowView)e.Row.DataItem)["downloadGuid"]);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top