Multiple Parameters With Hyperlink in DataGrid

Discussion in 'ASP .Net Building Controls' started by eRic, Jul 10, 2003.

  1. eRic

    eRic Guest

    I have a datagrid with a hyperlinkcontrol column. And it will only take one
    parameter. So I created a template column, with a hyperlink based on an
    example I saw. (now working directly in the aspx page as opposed to the code
    behind) It uses the NavigateURL and then useses
    Container.DataItem("itemName") to set the item values inline (so
    'someUrl.com?item=.' + Container.DataItem("itemName") ) First off I'm doing
    this in C# so I changed the call to Container.DataItem["itemName"]. Now it
    throwsa HTML excepetion because the "object" cannot be index. any
    suggestions on how to do this. I have tried casting the container but to no
    avail.

    My overall goal is to pass 2 parameters in a query string of a hyperlink
    that is embeded in a datagrid. :)

    THANKS!!
    eRic
     
    eRic, Jul 10, 2003
    #1
    1. Advertisements

  2. Hi Eric,

    Could you post a code snippet along with the exact text for the error?

    --
    Victor Garcia Aprea
    Microsoft MVP | ASP.NET
    Looking for insights on ASP.NET? Read my blog:
    http://obies.com/vga/blog.aspx

    To contact me remove 'NOSPAM'. Please post all questions to the newsgroup

    and not by private mail.
     
    Victor Garcia Aprea [MVP], Jul 12, 2003
    #2
    1. Advertisements

  3. [borrowing Victor's post because I lost the original on my newsspool]
    Just as a note...

    It might be a little bit cheesy, but why not build the query string for each
    row in SQL (something like like SELECT 'item1=' + item1 + '&item2=' + item2
    AS QueryString) and then use that in your datagrid?
     
    David Rothgery, Jul 12, 2003
    #3
  4. eRic

    Joe Glover Guest

    Hi eRic

    Forgetting about template columns for the time being, I think the following
    should work for you:

    <asp:HyperLinkColumn DataNavigateUrlField="itemName"
    DataNavigateUrlFormatString="someUrl.com?item={0}"
    DataTextField="itemName"></asp:HyperLinkColumn>

    HTH
    Joe
     
    Joe Glover, Jul 13, 2003
    #4
  5. eRic

    Eric Adler Guest

    Yeah, adding 1 parameter to the query string is straight forward,
    unfortuately I was trying to add at least 2 parameters. That's why I
    needed the template column and the hyperlink control
     
    Eric Adler, Jul 19, 2003
    #5
  6. eRic

    Eric Adler Guest

    Shoot I wish I had captured the error better. I had a tight deadline so
    I need came up with a different solution. One where I only needed the
    one, easy, query string value. So, in your opinion, was I on the right
    track?
     
    Eric Adler, Jul 19, 2003
    #6
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.