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. Advertising

  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.
    "eRic" <> wrote in message
    news:...
    > 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
    >
    >
     
    Victor Garcia Aprea [MVP], Jul 12, 2003
    #2
    1. Advertising

  3. "Victor Garcia Aprea [MVP]" <> wrote in message
    news:...
    [borrowing Victor's post because I lost the original on my newsspool]

    > "eRic" <> wrote in message
    > news:...
    > > 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. :)


    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?



    --
    Dave Rothgery
     
    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

    "eRic" <> wrote in message
    news:...
    > 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
    >
    >
     
    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

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    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?


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Eric Adler, Jul 19, 2003
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?R3JlZyBSZXlub2xkcw==?=

    How to pass multiple hyperlink parameters with datagrid

    =?Utf-8?B?R3JlZyBSZXlub2xkcw==?=, Oct 20, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    4,595
    Shiva
    Oct 20, 2004
  2. LB
    Replies:
    1
    Views:
    1,177
    Patrick Olurotimi Ige
    Apr 1, 2005
  3. davetichenor
    Replies:
    1
    Views:
    850
    Eliyahu Goldin
    Oct 30, 2006
  4. eRic

    Multiple Parameters With Hyperlink in DataGrid

    eRic, Jul 10, 2003, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    121
  5. LB

    multiple parameters for a datagrid url hyperlink

    LB, Mar 31, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    124
Loading...

Share This Page