DataNavigateUrlFormatString Question

lorena

Centurion
Joined
Oct 23, 2003
Messages
134
Location
Phoenix, Arizona
I have a form with a datagrid and I would like to be able to change a portion of the DataNavigateUrlFormatString depending on other factors in the web app.
Here is my code:
Visual Basic:
<asp:HyperLinkColumn HeaderText="Details" Text="View Details" DataNavigateUrlField="Req_ID" Target="_blank"						DataNavigateUrlFormatString="mgrid_details.aspx?id={0}&cat=0" />
Specifically, I want to change "cat=0" to "cat=5" depending on whether the record will be editable or not.
Is there a way to do this?
 
SOLVED!Found the solution in Scott Mitchell's "ASP.NET Data Controls". Here is what worked:
Visual Basic:
If e.Item.ItemType <> ListItemType.Header And _
      e.Item.ItemType <> ListItemType.Footer Then
      Dim hl As HyperLink = e.Item.Cells(0).Controls(0)
      Dim navURL As String
      hl.Text = "View Details"
      Select Case intCat
        Case 10, 20
          navURL = "mgrid_details.aspx?cat=0&id=" & _
            Server.UrlEncode(DataBinder.Eval(e.Item.DataItem, "req_id"))
        Case 35, 45, 55
          navURL = "mgrid_details.aspx?cat=5&id=" & _
            Server.UrlEncode(DataBinder.Eval(e.Item.DataItem, "req_id"))
      End Select
      hl.Target = "_blank"
      hl.NavigateUrl = navURL
So, if anyone else encounters this problem, I hope this helps
 
Back
Top