changing hyperlinks within item templates at runtime

P

Paul

There are a number of places in my app where I want the user to work
with an item (a real physical item referred to by its stock number) If
such an item hasn't been selected, I redirect the user to a page to
select one. Then having selected one, want to redirect them back from
where they came (passing the stockitemID ). It's this latter part
(redirection from where they came) that's bugging me.

I'm using a datagrid to display the items that fit the search criteria.
One of the columns is a hyperlink that needs to redirect the user back
to the page that they came from.

At 1st when I had only one page, I hard coded the return page like this:

<item template>
<a href='returnpage.aspx?itemid=<#%databinder.eval(container.dataitem,
"ID")%>.... and the rest..... </a>
</item template>

I need to change "returnpage.aspx" to reflect the page that the user
came from. It's not getting the value that's the problem, it's getting
that value into the above statement!

Subsequently, I made the item template contain <an asp:hyperlink> in the
hope that I could manipulate the navigateURL property in the code
behind. However, I get an "Object reference not set to an instance of
an object" error when I try that. (It seems that "ids" of items within
datagrids aren't what they seem!)

I thought of passing the returnURL to the SQL server stored proc and
passing it back again. That would definitely work (I could refer to the
return page using the

<%# databinder.eval.....%>

syntax, but it seems very silly to pass a parameter only to return it
back again!


There must be another way! Any advice gratefully received.
 
G

Guest

Paul, there are a couple ways to go, but here's one: return the string for your "return page" from a public function of the page class, then use something like..

href='<%# MyReturnPage() + databinder.eval(etc.) %>

hth

Bil

----- Paul wrote: ----

There are a number of places in my app where I want the user to work
with an item (a real physical item referred to by its stock number) If
such an item hasn't been selected, I redirect the user to a page to
select one. Then having selected one, want to redirect them back from
where they came (passing the stockitemID ). It's this latter part
(redirection from where they came) that's bugging me

I'm using a datagrid to display the items that fit the search criteria.
One of the columns is a hyperlink that needs to redirect the user back
to the page that they came from

At 1st when I had only one page, I hard coded the return page like this

<item template><a href='returnpage.aspx?itemid=<#%databinder.eval(container.dataitem,
"ID")%>.... and the rest..... </a></item template

I need to change "returnpage.aspx" to reflect the page that the user
came from. It's not getting the value that's the problem, it's getting
that value into the above statement

Subsequently, I made the item template contain <an asp:hyperlink> in the
hope that I could manipulate the navigateURL property in the code
behind. However, I get an "Object reference not set to an instance of
an object" error when I try that. (It seems that "ids" of items within
datagrids aren't what they seem!

I thought of passing the returnURL to the SQL server stored proc and
passing it back again. That would definitely work (I could refer to the
return page using th

<%# databinder.eval.....%

syntax, but it seems very silly to pass a parameter only to return it
back again


There must be another way! Any advice gratefully received
 

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

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top