Multiple Parameters With Hyperlink in DataGrid

E

eRic

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
 
V

Victor Garcia Aprea [MVP]

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

David Rothgery

[borrowing Victor's post because I lost the original on my newsspool]
eRic said:
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?
 
J

Joe Glover

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
 
E

Eric Adler

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
 
E

Eric Adler

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?
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top