Bunch's Blog

One day I'll have a catchy subtitle, one day
posts - 77, comments - 89, trackbacks - 0

My Links

News

Tag Cloud

Archives

Green

NavigateUrl and EVAL

Here is how you can add a database value to the URL of a HyperLink that is in a GridView. In this example the text displayed is the same as the value added to the URL. Also the data is bound through a SqlDataSource and the “ID” value is from the output of the Select statement the SqlDataSource uses. This is a quick way to put the data in the URL without using any code in the code behind.

<asp:TemplateField HeaderText="ID" >

   <ItemTemplate>

<asp:HyperLink ID="hlID" runat="server" Text='<%# EVAL("ID") %>'                NavigateUrl='<%#"Default.aspx?ID=" + EVAL("ID") %>'/>

   </ItemTemplate>

</asp:TemplateField>

Technorati Tags: ,
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Print | posted on Wednesday, July 30, 2008 2:45 PM |

Feedback

Gravatar

# re: NavigateUrl and EVAL

i was looking everywhere for an example that WORKS

thanks!!!
11/5/2008 6:28 AM | sudhir
Gravatar

# re: NavigateUrl and EVAL

Thank you!
This issue has taken me all day.
The cheque is in the post ;)
1/28/2009 9:56 AM | Billy
Gravatar

# re: NavigateUrl and EVAL

Awesome! Thanks.
2/10/2009 10:41 AM | Brownie
Gravatar

# re: NavigateUrl and EVAL

Thankyou so much
3/22/2009 10:36 PM | aspci
Gravatar

# re : Navigate Url

its very useful code
1/19/2010 1:32 AM | ewitttas
Gravatar

# re: NavigateUrl and EVAL

Can anyone explain why I encountered an error...
I used the code as shown and it said there was an input error and the string wasn't properly formed. I changed the '+' to an '&' and it works fine and correctly.

Chris

P.S. Sorry the topics a bit old, very helpful though and just what I needed!
4/12/2010 7:26 AM | Chris
Gravatar

# re: NavigateUrl and EVAL

<asp:HyperLink ID="Gebruiker" runat="server" Text="Gebruikernr" NavigateUrl='<%#"About.aspx?usernr"= DataBinder.Eval(Container,"UserID") %>'></asp:HyperLink>

This part of code results in an error telling : The left side of an assignment should be a variable or property. However, I can't find the problem. Only one thing is not that clear to me: the "UserID", is this a name that has to be equal to sth in the database, or where do I get this from??
9/22/2010 2:21 PM | Kris
Gravatar

# re: NavigateUrl and EVAL

exactly what I am looking for - thanx alot!
9/28/2010 10:53 AM | vitellius
Gravatar

# re: NavigateUrl and EVAL

thanks ;]
11/14/2011 9:05 AM | s
Gravatar

# re: NavigateUrl and EVAL

Hi thank you it was working for me
12/19/2011 12:31 AM | balaji
Gravatar

# re: NavigateUrl and EVAL

Works great. Thanks.
12/20/2011 12:04 PM | Chris Doan
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 
 

Powered by: