Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 8th, 2006, 09:28 AM
Registered User
 
Join Date: Jun 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default DataNavigateUrlFormatString

This is my first post - I hope I am posting in the right place.
I have a form with a datagrid and I would like to be able to change a portion of the DataNavigateUrlFormatString depending on whether or not the edit column in the subform will be visible.

Here is my code:

<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.
I think it may be something to do with ItemDataBound but I am not sure
Is there a way to do this?

 
Old June 8th, 2006, 02:05 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

Yes, that probably is right; I haven't done this, but in the e.Item for the row, get the cell, then it probably creates a link control that you access through e.Item.Cells(index).Controls(0). You convert it to the appropriate type and parse the NavigateUrl property.

Brian
 
Old June 8th, 2006, 02:53 PM
Registered User
 
Join Date: Jun 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The problem is that the grid is not in edit when the link is clicked. So there is no template column/e.item to reference.The first page displays a list of records with the Edit either visible or not visible depending on whether or not the records are active (can be edited) or closed (can not be edited). When the user clicks on "View Details" another page launches displaying only the data for the selected record. My hope was to be able to change the url for "View Details" so it would load with cat=0 or cat=5.
I may have to resort to using ViewState to get the page to do what I want it to do. I am just not sure how to do this.

 
Old June 8th, 2006, 05:47 PM
Registered User
 
Join Date: Jun 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

SOLVED!Found the solution in Scott Mitchell's "ASP.NET Data Controls". Here is what worked:
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






Similar Threads
Thread Thread Starter Forum Replies Last Post
DataNavigateUrlFormatString mparr_1972 Classic ASP Basics 3 July 18th, 2006 10:44 AM
Setting DataNavigateURLFormatString in datagrid Renu ASP.NET 1.0 and 1.1 Basics 1 December 9th, 2004 01:32 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.