Results 1 to 5 of 5

Thread: [RESOLVED] Want to create NavigateUrl string in my code

  1. #1

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    My Mustang GT
    Posts
    4,562

    Resolved [RESOLVED] Want to create NavigateUrl string in my code

    I'll make this short and sweet: I want to generate the NavigateUrl string for a hyperlink in my code, because I create the HyperLink column in my code. So I want to do something like this:

    Code:
                    Dim hyFactor As HyperLink = DirectCast(Me.gvL.Rows(i).FindControl("hyFactor"), HyperLink)
                    hyFactor.Text = sFactor
                    hyFactor.NavigateUrl = "Edit_Loss.asp"
    sFactor came from a database call I just made.

    And that works. The trouble is I want to pass to Edit_Loss.asp two parameters whose values depend on the current row in the grid. So it would look something like:

    Edit_Loss.asp?param1={0}&param2={1}, but in vb how do I tell it where to get 0 and 1 from? Is this doable?

    Thanks.

  2. #2

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    My Mustang GT
    Posts
    4,562

    Re: Want to create NavigateUrl string in my code

    Alternatively, when my asp file does a request("param1") what are my choices, in my aspx file that call the asp file, of ways to give it a param1? In other words, what is the source that the request() goes to to get the value it's looking for?

    Thanks.

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Want to create NavigateUrl string in my code

    You have "i" which is the row in your gridview you're dealing with. Using i, you can also query the datasource of the gridview. Cast the grid's source to dataset, or dataview or datatable or whatever it allows. Once you have that, you have the 'collection'. You can then use i to get the specific property you want, for example

    DataSet.Tables(0).Rows(i).Item("field1").ToString() and DataSet.Tables(0).Rows(i).Item("field9").ToString()

  4. #4

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    My Mustang GT
    Posts
    4,562

    Re: Want to create NavigateUrl string in my code

    Thank you, mendhak.

    I think I was making more of it that it was, and it's really just a string operation. So I am doing it like this:
    Code:
                For i As Integer = 0 To Me.gv.Rows.Count - 1
                    Dim labelAbbrev As Label = DirectCast(Me.gv.Rows(i).FindControl("lblAbbrev"), Label)
    
                    GetData(labelAbbrev.Text, sIk, sTax, sFromDate, sToDate, sUpDate)
    
                    Dim hyTax As HyperLink = DirectCast(Me.gv.Rows(i).FindControl("hyTax"), HyperLink)
                    hyTax.Text = sTax
                    hyTax.NavigateUrl = "Edit_Tax.asp?tax_ik=" + sIk + "&ldc_abbr=" + labelAbbrev.Text
    
    Next

  5. #5
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Want to create NavigateUrl string in my code

    Quote Originally Posted by MMock

    Dim hyTax As HyperLink = DirectCast(Me.gv.Rows(i).FindControl("hyTax"), HyperLink)
    Woohoo!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width